Question

While working on an existing open source firefox addon to improve it I found the following code piece but couldn't figure out the usage of key work "key" in key="selenium-builder-run-key" line

    <menupopup id="menuWebDeveloperPopup"> 
        <menuitem
            label="&runseleniumbuilder;"
            key="selenium-builder-run-key"
            oncommand="bridge.boot()" />
    </menupopup>

What does it do though I am aware that menuWebDeveloperPopup is id for web developer menu present in tool bar.

What does

            key="selenium-builder-run-key"

do in the above snippet?

strangely one para below the above one is

    <menupopup id="appmenu_webDeveloper_popup"> 
        <menuitem
            label="&runseleniumbuilder;"
            key="selenium-builder-run-key"
            oncommand="bridge.boot()" />
    </menupopup>

but I couldn't find any dom with such a ID though Firefox extension elements id mentions that appmenu_webDeveloper_popup could be found in http://mxr.mozilla.org/mozilla-central/source/browser/base/content/browser.xul. I dont find it. Is it removed or deprecated?

Was it helpful?

Solution

The key attribute is a reference to a XUL <key> element that specifies a keyboard shortcut for that menuitem.

In this, case, the add-on contains:

<key id="selenium-builder-run-key"
                modifiers="accel alt"
                key="B"
                oncommand="bridge.boot()" />

Which means a <menuitem> with key="selenium-builder-run-key" can be activated by pressing "Control-Alt-B" on the keyboard (or Command-Opt-B on a Mac).

As for your other question, searching for that ID in an old version of Firefox finds it in one of the files included by browser.xul, but it looks like it's been removed in newer versions of Firefox.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top