Created
August 7, 2014 16:25
-
-
Save ZER0/10ef3b4b491c1dac3d70 to your computer and use it in GitHub Desktop.
ToggleButton with Global and Tab scope checked status
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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