views:

21

answers:

1

Hello,

I'm trying to build a firefox addon & I want to add image/icon in the right click content menu , for example, firebug had an icon in the right click context menu, http://i.imgur.com/GjGAV.jpg

I wanna do something similar, my addon also consists of menu items

structure of my addon in context menu :

[icon] [menu] 
            [menu item 1]
            [menu item 2]
            [menu item 3]
            [menu item 4]

How can I do it ?

Thanks !

+2  A: 

You have to set the image attribute, give the element the class menu-iconic and store the image so that you can access it.

XUL:

<menu id="someid" label='your label'
          class="menu-iconic"
          image='chrome://addon/skin/image.png'>
...
</menu>

JavaScript:

You can also set or change the image dynamically (get a reference to the element first):

menu.setAttribute('image', 'chrome://addon/skin/image.png');
Felix Kling
Thank you, It worked :), struggling to this for the past 2 hours, finally `class = "menu-iconic"` made my job get done. but one question, how does it got iconic on adding a `class` attribute ?
Well I guess that Firefox uses some CSS to show the image and maybe also align the text correctly. In the end, the XUL interface is also just styled with CSS.
Felix Kling