views:

337

answers:

1

I'd like to be able to detect keyboard input (namely the TAB key) when an SWT menu is open, but it doesn't seem to broadcast any events when listeners are added with the addListener method, and there are no addKeyListener or addTraverseListener methods.

I've also tried adding listeners to the control to which the menu is added (it's a popup menu) as well as the shell, but key events don't make it to those objects either.

It looks like the menu is an OS level control that eats up keyboard events. Has anyone found a way to grab keystrokes from a popup menu? Or is the only option to make my own non-OS popup menu?

A: 

You are correct that the SWT menu is a native windowing-system menu. I'm not sure what you mean by the verb "traverse" in this context. Do you mean "hilight for possible selection"? I believe that, in SWT, that is called "arming", and you can indeed add listeners for arming events. See this snippet.

If I've completely misunderstood your question, then let me know in a comment, and I'll delete.

Jonathan Feinberg
When I say "traverse" I mean I want to close the menu and activate another control -- so traversing BETWEEN the menu and another widget, not WITHIN the menu widget. I've never seen the "arm" event before, but I don't think it gets me where I want to go.
thehiatus