Skip to content

Instantly share code, notes, and snippets.

@ZER0
Created August 7, 2014 16:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZER0/10ef3b4b491c1dac3d70 to your computer and use it in GitHub Desktop.
Save ZER0/10ef3b4b491c1dac3d70 to your computer and use it in GitHub Desktop.
ToggleButton with Global and Tab scope checked status
const { ToggleButton } = require('sdk/ui/button/toggle');
let globalToggle = ToggleButton({
id: 'my-global-toggle',
label: 'global function',
icon: './foo.png',
onChange: function() {
// delete the window state for the current window,
// automatically set when the user click on the button
this.state('window', null);
// now that the state hierarchy is clean, set the
// global state
this.checked = !this.checked;
}
});
let tabToggle = ToggleButton({
id: 'my-global-toggle',
label: 'global function',
icon: './foo.png',
onChange: function() {
// delete the window state for the current window,
// automatically set when the user click on the button
this.state('window', null);
// now that the state hierarchy is clean, set the
// tab state for the current tab
let { checked } = this.state('tab');
this.state('tab', {checked: !checked});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment