Skip to content
This repository has been archived by the owner on Sep 9, 2022. It is now read-only.

Add a toolbar button context menu checkbox to toggle the number #1097

Closed
tophf opened this issue Mar 26, 2015 · 4 comments
Closed

Add a toolbar button context menu checkbox to toggle the number #1097

tophf opened this issue Mar 26, 2015 · 4 comments

Comments

@tophf
Copy link

tophf commented Mar 26, 2015

Why?

Because as a user I see a button and I want to customize its appearance so what do I do? I right-click it and immediately see the related checkbox. Easy.

Docs
The manifest should have contextMenus in permissions.
Here's an example:

chrome.contextMenus.create({
    id: "toggleNumber", title: chrome.i18n.getMessage("toggleNumberLabel"),
    type: "checkbox", contexts: ["browser_action"], checked: getPref("toggleNumber")
});
chrome.contextMenus.onClicked.addListener(function(info, tab) {
    if (info.menuItemId == "toggleNumber") {
        setPref(info.menuItemId, info.checked);
        updateToolbarButtonNumber();
    }
});
chrome.extension.onMessage.addListener(function(request, sender, sendResponse) {
    if (request.method == "prefChanged"  && request.prefName == "toggleNumber") {
        chrome.contextMenus.update("toggleNumber", {checked: request.value});
    }
});

The options page should notify the background page:

chrome.extension.sendMessage({method: "prefChanged", prefName : "toggleNumber", value: newValue});

Actually it'd be reasonable to include the other three global behavior options as well!

@gorhill
Copy link
Contributor

gorhill commented Mar 26, 2015

Sorry, such a global setting does not have a place in a context menu.

@gorhill gorhill closed this as completed Mar 26, 2015
@tophf
Copy link
Author

tophf commented Mar 26, 2015

Well, the toolbar button context menu has a much more global stuff like "Remove from Chrome", "Manage extensions" and so on. It's quite evident that your justification was invalid.

@gorhill
Copy link
Contributor

gorhill commented Mar 26, 2015

global stuff like "Remove from Chrome"

Oh ok, you mean the icon's context menu, I thought you meant the page's context menu.

@gorhill gorhill reopened this Mar 26, 2015
@tophf
Copy link
Author

tophf commented Mar 26, 2015

And there I thought the screenshot isn't needed, oh boy :-) Now I'll be always providing one, just in case 😀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants