Thanks for the hint. 

I added a listener for onkeyup and listened for event.getKeyIdentifier()
== "Apps", then generated the event.

A bit more was needed in the event:

               var oElement = this.getElement();
               var oPosition = qx.bom.element.Location.get(oElement);
               var oContextInfo =
                  {
                  target : oElement,
                  type   : "contextmenu",
                  preventDefault : function() {},
                  clientX : oPosition.left,
                  clientY : oPosition.top
                  };
 
qx.event.handler.EventHandler.getInstance()._onmouseevent(oContextInfo);
               break;

The preventDefault function was needed because I prevent the default menu
appearing in the context menu handler. And then I position the context
menu using clientX and clientY of the event, so I had to preset that from
the element.

For tables it's a bit more complicated as the focused row should be used
for position.

               var scroller = this.getPaneScroller(0);
               var pane = scroller.getTablePane();
               var oElement = pane.getElement();
               var oPosition = qx.bom.element.Location.get(oElement);
               var nFirstRow = pane.getFirstVisibleRow();
var nRowOffset = (this._focusedRow - nFirstRow) *
this.getRowHeight() + this.getRowHeight() / 2;
               var oContextInfo =
                  {
                  target : oElement,
                  type   : "contextmenu",
                  preventDefault : function() {},
                  clientX : oPosition.left + 10,
                  clientY : oPosition.top + nRowOffset
                  };

I have an issue in that after showing the menu, focus isn't set correctly
back to the table. Pressing tab activates the button to show the header
menu, and then shift-tab re-activates the table. I have debug statements
on onkeydown etc, and they don't activate with the first tab. So
something else has keyboard focus after the menu is shown.
               
> >  If I right-click on a table or tree widget I get a context menu. 
> How can
> >  I wire this up to the keyboard so that the context menu appears 
> > when the
> >  appropriate key is pressed on the keyboard (under Windows there 
> > could be
> >  a dedicated key, or shift+F10).
> >
> >  This would make it possible to test menus via Selenium.
> 
> It looks like you should be able to do something like this to 
> simulate it:
> 
> var event =
> {
>   target : yourWidget.getElement(),
>   type   : "contextmenu"
> };


Hugh

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
qooxdoo-devel mailing list
qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to