QUOTE(vizskywalker @ Dec 8 2005, 05:05 AM)
O looked at the code in credits.js and found the following function: creditsClicked(event). THis function had a handler for if the credits were clicked with left mouse button, but no right mouse button handler.
CODE
// Function to handle mouse-click on Statusbar Item
function creditsClicked(event) {
// Left button click
if ( event.button == 0 ) {
// Refresh the stats
refreshCredits();
return true;
}
} // end function
That's not where the menu's specified. Infact XUL provides you with a very efficient mechanism of linking pop-up menu's with right-click. You do not need to define the right-click event. What you see here is for the left-click, since if calls a DISTINCT funtion - so the button has to be checked for and the required routine called.
But first - a short word about the structure of extensions. Firefox extensions are typically built by using a combination of XUL and Javascript files. XUL files are the ones which define and give shape to your extension - or in other words, are responsible for the VISUAL MANIFESTATION (UI) of your extension - and also links the appropriate Javascript routines with these VISUAL ELEMENTS.
The actual Javascript routines are usually placed in another file with a matching filename - as in this case, credits.xul and credits.js. They carry out whatever-is-to-be-done when a UI element receives a particular EVENT - such as a Key-Click or Mouse-Click.
As for the right-click menu, think of it as the same kind that you get in almost all applications in Windows - it's commonly known as the
CONTEXT MENU. Take a look into the
credits.xul file. Around line 12, you'll find a section like the following:
CODE
<popupset>
<popup id="configMenu" position="after_start">
<menuitem label="&crs.config;" accesskey="&crs.config.accesskey;" oncommand="creditsOptions();" />
<menuitem label="&crs.visit;" accesskey="&crs.visit.accesskey;" oncommand="visitHostingForum();" />
<menuseparator/>
<menuitem label="&crs.about;" accesskey="&crs.about.accesskey;" oncommand="aboutDialog();" />
</popup>
</popupset>
This is what defines a popup menu with the name/id
configMenu, and associates three menuitems with it - each of which call a particular function upon being clicked. Notice how the
popupset - which stands for a pop-up control encloses the menu items individually define by the
menuitem tags. Also notice each item is linked with a corresponding routine using the
oncommand attribute. These routines, as I mentioned earlier, can be found in the credits.js file.
Next look a little down - same file around line 25.
CODE
<statusbar id="status-bar">
<statusbarpanel id="hostingCreditsStatus" style="width: 150px;" context="configMenu" onclick="return creditsClicked(event);">
<hbox>
<image id="creditsIcon" src="chrome://creditsreporter/skin/alert_blue.gif" />
<!-- <label id="creditsTitle" value="&crs.credits;" style="width: 65px;" align="left" /> -->
<label id="creditsLabel" value="0" align="left" />
</hbox>
</statusbarpanel>
</statusbar>
The first element defined is the statusbar - which tells FF to add whatever is enclosed in between into the statusbar. The immediately next tag defines a
statusbarpanel - a panel, which encases further controls - itself being a distinct segment in the statusbar.
This is where we define the context menu - which by default comes up using the right-click. See how this statusbarpanel defines an attribute called
context - which directly points to the pop-up element. This is a very clever trick I must say .. instead of trying to define a context menu using javascript and what not, you simply define a separate pop-up and link that to the context of some other element.... This entirely eliminates the need to write separate event handlers for the right-click.
QUOTE
Also, in options.js there did not seem to be any code for a menu, nor was there in credits.js
So either, a) you don't have them in this version, or

something went terribly wrong. And you probably know this, but the number for the event.button to handle right click is 2 (cause 1 is mouse wheel).
~Viz
Check out your files and see if you can spot the abovementioned portions. I've checked and rec-checked many times over and it ALWAYS comes up for me.. the code is also there in the files I'd uploaded..
So let me know - this is a very baffling problem.. might be I'll have to head for the mozdev forums.
Regards,
m^e
Comment/Reply (w/o sign-up)