Firefox's add-on SDK: no tooltip for context-menu? -


in official documentation context-menu not mentioned tooltip. not possible show pop-up text when user hover on item menu?

it possible, code.

first need dummy menu item serve trigger , subsequently add tooltips actual menu items.

it easy find out menu items constructed addon-sdk module because have class addon-context-menu-item. difficult part identify belong extension.

one way achieve utilize data attribute of item class constructor, conveniently maps value attribute of underlying xul element.

so if data consists of unique prefix , desired tooltip text, matter of kicking in right moment.

const { getmostrecentbrowserwindow } = require("sdk/window/utils");    var cm = require("sdk/context-menu");  var uuid = require('sdk/util/uuid').uuid();  var uuidstr = uuid.number.substring(1,37)    cm.item({    label: "my menu item",    context: cm.urlcontext("*.mozilla.org"),    data: uuidstr+"this cool tooltip"  });    cm.item({    label: "global item",    data: uuidstr+"tooltips ftw"  });    cm.item({    label: "just tigger, never show up",    contentscript: 'self.on("context", function(){self.postmessage(); return false;})',    onmessage: function(){      var chromewin = getmostrecentbrowserwindow();      var cmitems = chromewin.document.queryselectorall(".addon-context-menu-item[value^='"+ uuidstr +"']");      for(var i=0; < cmitems.length; i++)        cmitems[i].tooltiptext = cmitems[i].value.substring(36);    }  })

if use data have work.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -