Detect when popup menu is open?

Howdy folks,

Is there any way to detect whether a popup menu is open?

I wish to halt certain operations based on whether the popup menu from the taskbar icon is open. I tried setting a variable to true when CreatePopupMenu is called and setting it to false when a menu item is selected, but this doesn’t work for the case when I click outside the menu to dismiss it without making a selection. I dug through the wxpython code a bit to look for something like the IsShown method for frames, but no equivalents exist for the popup menu.

Thanks,
Shultz

···

See how Windows Mobile brings your life together—at home, work, or on the go. See Now

Hi,

I had a similar problem and managed to get it to work by using a flag. I did something like this from the event handler inside my class:

self.popup_is_shown = True
self.PopupMenu(my_menu)
my_menu.Destroy()
self.popup_is_shown = False

'self' refers to your class that must inherit from something that has the function PopupMenu.

Hope it helps,
Max

Cerulean Skies wrote:

···

Howdy folks,

Is there any way to detect whether a popup menu is open?

I wish to halt certain operations based on whether the popup menu from the taskbar icon is open. I tried setting a variable to true when CreatePopupMenu is called and setting it to false when a menu item is selected, but this doesn't work for the case when I click outside the menu to dismiss it without making a selection. I dug through the wxpython code a bit to look for something like the IsShown method for frames, but no equivalents exist for the popup menu.

Thanks,
Shultz

------------------------------------------------------------------------
See how Windows Mobile brings your life together—at home, work, or on the go. See Now <http://clk.atdmt.com/MRT/go/msnnkwxp1020093182mrt/direct/01/&gt;
------------------------------------------------------------------------

_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Cerulean Skies wrote:

Howdy folks,

Is there any way to detect whether a popup menu is open?

I wish to halt certain operations based on whether the popup menu from the taskbar icon is open. I tried setting a variable to true when CreatePopupMenu is called and setting it to false when a menu item is selected, but this doesn't work for the case when I click outside the menu to dismiss it without making a selection. I dug through the wxpython code a bit to look for something like the IsShown method for frames, but no equivalents exist for the popup menu.

If you are not worried about portability to Mac then you can probably still handle the mouse events yourself in the taskbar icon, and then popup the menu yourself. Then you'll know when it is active or not. This is how the taskbar icon used to work, but because that model didn't fit with the dock icons on Mac it had to be adjusted to use the CreatePopupMenu interface instead.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!