-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi there,
I would like to achieve the following:
a) Focus the first menuitem in a contextual menu popup upon opening
b) Restore the focus to the component the contextual menu refers to upon closing
This is my test code:
<vbox> Right click the textbox <textbox id="tb" focus="true" context="menupopup, position=after_end" /> <label id="lbl" /> <menupopup id="menupopup" onOpen='if( event.isOpen() ) mi.setFocus( true ); else tb.focus(); lbl.setValue( event.isOpen()? "A": "B" );'> <menuitem id="mi" label="Some menu item" onOK='menupopup.close();' onClick='menupopup.close();'/> </menupopup> </vbox>
Upon right-clicking the textbox the menu popup gets opened and the onOpen event is fired, as demonstrated by the status label getting the value 'A'. The first menuitem however does not get focused at all.
When leaving the menupopup
a) If I do so by pressing the left arrow key no onOpen event is fired at all; I guest it nonetheless should, at least if the left arrow is meant as a mean of closing a popup via the keyboard. It would be nice if popups could be somehow configured to be closed by using ctrlKeys or Esc.
b) If I do so by clicking somewhere outside the popup the onOpen event is fired as expected
Any idea as to why menuitems are reluctant to get focused and how to leave popups using the keyboard while at the same time being able to catch the onOpen event?
With kind regards
César Varona
Asked: 2011-07-15 08:39:15 +0800
Seen: 244 times
Last updated: Jul 15 '11