Created
December 17, 2015 20:36
-
-
Save BGMcoder/f96a274d828a6d53f0a9 to your computer and use it in GitHub Desktop.
AddonSDK MouseOver Effect for Toolbar Buttons
This file contains 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 { 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