Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8219377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:08:11+00:00 2026-06-07T13:08:11+00:00

I am developing my first firefox extension so I created a menu-button element and

  • 0

I am developing my first firefox extension so I created a menu-button element and menu items.
Exactly like the FireBug button, I would like an event to be triggered when clicking on the main button, but also when clicking on a menu item. The problem is that when I click on the arrow next to the main button to display the menu items the main event is triggered. So my question is:

How do I differentiate the main button (the menu-button) and the arrow displaying the menu?

Here is my code generating the button:

function addToolbarButton() {
var document = mediator.getMostRecentWindow('navigator:browser').document;      
var navBar = document.getElementById('nav-bar');
if (!navBar) {
    return;
};

//main button
var btn = document.createElement('toolbarbutton');  
btn.setAttribute('id', 'reportButton'); 
btn.setAttribute('type', 'menu-button');  
btn.setAttribute('class', 'toolbarbutton-1'); 
btn.setAttribute('image', data.url('img/BookmarkKitchen.png'));
btn.setAttribute('orient', 'horizontal');
btn.setAttribute('label', 'Report');
btn.addEventListener('click', function() {
    console.log("this=" + this.id); 
    event.stopPropagation();
    }
, false);


//menu popup
var menupopup = document.createElement('menupopup');
menupopup.setAttribute('id', 'menupopup');
menupopup.addEventListener('click', function(event) {
    console.log("this=" + this.id);   
    event.stopPropagation();
}
, false);

//menu items
var menuitem1 = document.createElement('menuitem');
menuitem1.setAttribute('id', 'menuitem1');
menuitem1.setAttribute('label', 'Test1');
menuitem1.setAttribute('class', 'menuitem-iconic');
menuitem1.addEventListener('click', function(event) {
    console.log("this=" + this.id);  
    event.stopPropagation();
}
, false);


menupopup.appendChild(menuitem1);
btn.appendChild(menupopup);
navBar.appendChild(btn);



}

When I click on the main button, the console will write “this=reportButton”. This is normal but when I click on the arrow next to the main button, the console will also write “this=reportButton”. That means if I want to access the menu, the main event will be triggered. The only way I found to prevent this, is to press the button on the arrow, wait for the menu to show up and release it on a menu Item. This is not very user friendly and Firebug doesn’t have this problem…

I hope I was clear enough. Thanks for answering this 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T13:08:13+00:00Added an answer on June 7, 2026 at 1:08 pm

    Don’t use the click event – in XUL it really means a mouse click. So if the user triggers a button by other means (e.g. keyboard), the click event will not be triggered. You should use the command event instead – and it has the additional advantage that it won’t fire if the dropdown arrow is clicked.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been developing my first iPhone app part-time and would like to start using
I'm developing my first Eclipse RCP application and I would like to know how
I am developing my first Firefox extension and for that I need to get
Im currently developing my first application in PyQt4, and what i would like to
I am developing my first addon for Firefox, and I'm using the Extention Developer
I'm developing my first ASP.NET MVC app and what I'd like to accomplish is
I am developing my first Android application. I have created a relativelayout with two
I am developing a firefox extension which reads and writes to a sqlite database.
Now on my localhost I'm starting developing first simple web service using ruby 1.9.2
I'm developing my first iPhone app. One day, I renamed some files including xib

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.