Skip to content

Instantly share code, notes, and snippets.

@BGMcoder
Created December 17, 2015 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BGMcoder/f96a274d828a6d53f0a9 to your computer and use it in GitHub Desktop.
Save BGMcoder/f96a274d828a6d53f0a9 to your computer and use it in GitHub Desktop.
AddonSDK MouseOver Effect for Toolbar Buttons
const { browserWindows } = require("sdk/windows");
const { CustomizableUI } = require('resource:///modules/CustomizableUI.jsm');
const { viewFor } = require("sdk/view/core");
const { ActionButton } = require("sdk/ui/button/action");
var myButton = ActionButton({
id: "myButton",
label: "My Button",
icon: { "16": "./icon-16.png", "32":"./icon-32.png", "64": "./icon-64.png" },
onClick: function(state) {
console.log("My Button was clicked");
}
});
//create a mouseover effect for a control
exports.MouseOver = (whatbutton, whatwindow, whatfunction) =>{
CustomizableUI.getWidget( viewFor(whatbutton).id ).forWindow(whatwindow).node.addEventListener('mouseover', whatfunction, true);
};
function myMouseOverFunction(){
console.log("mousing over...");
}
//add events to the browser window
for(let w of browserWindows){
exports.MouseOver(myButton, viewFor(w), myMouseOverFunction); //add mouseover event to spatToggleButton
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment