Context menus are normally created with some state in mind, such as a range of selected tree items. This state may be required for commands contained in the context menu. In this case, you are expected to provide a context getter in the menu specification. The return value of the context getter will be used as the event object for any command dispatched from the menu.

Context getter for the ``Locals View'', from venkman-views.js...
console.views.locals.getContext =
function lv_getcx(cx)
{
    cx.jsdValueList = new Array();
    
    function recordContextGetter (cx, rec, i)
    {
        if (i == 0)
            cx.jsdValue = rec.value;
        else
            cx.jsdValueList.push(rec.value);
        return cx;
    };
    
    return getTreeContext (console.views.locals, cx, recordContextGetter);
}

The context object can be referenced in conditional attributes as cx. The utility function getTreeContext enumerates the selection for a given XUL tree, calling the recordContextGetter callback once for the primary selection, and then once for each item selected, if more than one row is selected. getTreeContext also points cx.target to the object representing the primary selection.

Context menu specification for the ``Locals View'', from venkman-views.js...
    console.menuSpecs["context:locals"] = {
        getContext: this.getContext,
        items:
        [
         ["set-eval-obj", {type: "checkbox",
                           checkedif: "has('jsdValue') && " +
                                      "cx.jsdValue.getWrappedValue() == " +
                                      "console.currentEvalObject",
                           enabledif: "has('jsdValue') && " +
                                      "cx.jsdValue.jsType == TYPE_OBJECT"}],
         ["-"],
         ["find-creator",
                 {enabledif: "cx.target instanceof ValueRecord && " +
                  "cx.target.jsType == jsdIValue.TYPE_OBJECT  && " +
                  "cx.target.value.objectValue.creatorURL"}],
<... snip ...>
        ]
    };