Changeset 8425

Show
Ignore:
Timestamp:
05/04/07 12:38:35 (21 months ago)
Author:
sjmiles
Message:

Generally ensure Shift-F10 triggers context menu "open" on IE/FF (and Opera) under various circumstances. Refs #2695.

Location:
dijit/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • dijit/trunk/Menu.js

    r8413 r8425  
    123123                //      return true to stop the event being processed by the 
    124124                //      parent popupmenu 
    125  
    126125                if(evt.ctrlKey || evt.altKey || !evt.keyCode){ return false; } 
    127126 
     
    219218                        node = dojo.withGlobal(win, dojo.body); 
    220219                } 
    221  
    222                 dojo.addListener(node, "contextmenu", this, this.open); 
     220                 
     221                // to capture these events at the top level,  
     222                // attach to document, not body 
     223                var cn = (node == dojo.body() ? dojo.doc : node); 
     224                node[this.widgetId+'connect'] = [ 
     225                        dojo.connect(cn, "oncontextmenu", this, "open"), 
     226                        dojo.connect(cn, "onkeydown", this, "_contextKey") 
     227                ]; 
    223228        }, 
    224229 
     
    226231                // summary: detach menu from given node 
    227232                var node = dojo.byId(nodeName); 
    228                 dojo.removeListener(node, "contextmenu", this.open); //PORT fix 3rd arg (handle) 
     233                dojo.forEach(node[this.widgetId+'connect'], dojo.disconnect); 
     234        }, 
     235 
     236        _contextKey: function(e){ 
     237                if (e.keyCode == dojo.keys.F10) { 
     238                        dojo.stopEvent(e); 
     239                        if (e.shiftKey && e.type=="keydown") { 
     240                                // FF: copying the wrong property from e will cause the system  
     241                                // context menu to appear in spite of stopEvent. Don't know  
     242                                // exactly which properties cause this effect. 
     243                                var _e = { target: e.target, pageX: e.pageX, pageY: e.pageY }; 
     244                                _e.preventDefault = _e.stopPropagation = function(){}; 
     245                                // IE: without the delay, focus work in "open" causes the system  
     246                                // context menu to appear in spite of stopEvent. 
     247                                window.setTimeout(dojo.hitch(this, function(){ this.open(_e); }), 1); 
     248                        } 
     249                } 
    229250        }, 
    230251 
     
    247268                // summary 
    248269                //              Open menu relative to the mouse 
     270                dojo.stopEvent(e); 
    249271                dijit.util.PopupManager.open(e, this); 
    250                 dojo.stopEvent(e); 
    251272                this._highlightOption(1); 
    252273        }, 
  • dijit/trunk/tests/test_Menu_Debuggable.html

    r8403 r8425  
    1313        djConfig = { isDebug: true, baseUrl: "../../dojo/"  }; 
    1414</script> 
     15 
    1516<script type="text/javascript" src="../../dojo/_base/_loader/bootstrap.js"></script> 
    1617<script type="text/javascript" src="../../dojo/_base/_loader/loader.js"></script> 
     
    3132<!--<script type="text/javascript" src="../../dojo/dojo.js" djConfig="isDebug: true, debugAtAllCosts: true"></script>--> 
    3233 
     34<script type="text/javascript" src="../util/PopupManager.js"></script> 
    3335<script type="text/javascript" src="../Menu.js"></script> 
    3436<script type="text/javascript" src="../util/parser.js"></script> 
     
    3840        dojo.require("dijit.util.parser");      // scan page for widgets and instantiate them 
    3941</script>--> 
     42 
    4043</head> 
    4144<body class="tundra"> 
  • dijit/trunk/util/PopupManager.js

    r8403 r8425  
    2222 
    2323                var x = e.pageX, y = e.pageY; 
     24                // FIXME: consider skipping everything up to _open 
     25                // if x == y == 0, allowing the popup to appear  
     26                // wherever it was last time.  
    2427                var win = dijit.util.window.getDocumentWindow(e.target.ownerDocument); 
    2528                var iframe = win._frameElement || win.frameElement;