Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.