|
Re: use of MenuDetect event ? [message #441660 is a reply to message #441641] |
Thu, 19 August 2004 11:12 |
Paul Singleton Messages: 37 Registered: July 2009 |
Member |
|
|
Larry Bergman wrote:
> I'm trying to detect SWT popup menus. I've registered for MenuDetect
> events, but these are produced by any right-click, whether or not a menu
> is actually displayed. Looking at the code for Control.showMenu, it looks
> to me like the MenuDetect event should be sent when the menu is set
> visible, not in all cases. Am I misinterpreting the meaning of this
> event? If so, is there another way I can detect popups?
Yes I think you misinterpret MenuDetect, which reports
a *request* for a context menu, whether or not the control
has a popup menu. Maybe it shoulda been called ContextRequest...
Perhaps you need to handle the Show event from the popup?
Although depending why you are trying to detect popup menus,
maybe MenuDetect *is* right for you after all, it just needs
a bit of a rethink.
I generate dynamic context menus for individual tree items and
table cells by catching "MenuDetect" then repopulating and
showing the root shell's popup at the reported x/y.
Beware some shortcomings in keyboard-generated MenuDetect
events: you get the current mousepointer coords as event.x & .y,
with no indication that these are inappropriate (misleading),
so the (possibly multiple) selection on which a key-driven
context request has been raised cannot reliably be identified.
But under the assumption that they are mouse-generated, they seem
great (haven't tried non-Windows).
Paul Singleton
|
|
|
Powered by
FUDForum. Page generated in 0.03605 seconds