dabo Commit
Revision 4473
Date: 2008-08-27 15:43:18 -0700 (Wed, 27 Aug 2008)
Author: Nate
Trac: http://svn.dabodev.com/trac/dabo/changeset/4473
Changed:
U trunk/dabo/ui/uiwx/dMenu.py
U trunk/dabo/ui/uiwx/dPemMixin.py
Log:
I think I have a working solution for this menu enable problem. I have
eliminated all calls to wx events in dMenu. I have the dForm process all menu
events. If the menu event has a NoneType object for evt.Menu, don't propagate
the event because it's a sub-menu. I also changed the _setDynamicEnabled
method to look evaluate the children of sub-menus as well.
Also, if an accelerator or hot-key is used, the MenuOpen event fires and the
DynamicEnabled properties get evaluated before the menu event is selected.
Diff:
Modified: trunk/dabo/ui/uiwx/dMenu.py
===================================================================
--- trunk/dabo/ui/uiwx/dMenu.py 2008-08-27 21:28:29 UTC (rev 4472)
+++ trunk/dabo/ui/uiwx/dMenu.py 2008-08-27 22:43:18 UTC (rev 4473)
@@ -38,46 +38,7 @@
self._daboChildren = {}
pm.dPemMixin.__init__(self, preClass, parent, properties,
attProperties, *args, **kwargs)
- # Could be that we are used without a Dabo app object (not
recommended,
- # but should be possible). So use the wx-method for getting the
uiApp ref,
- # instead of the Dabo way of self.Application.uiApp
- uiApp = wx.GetApp()
- uiApp.Bind(wx.EVT_MENU_OPEN, self.__onWxMenuOpen)
- uiApp.Bind(wx.EVT_MENU_CLOSE, self.__onWxMenuClose)
- if self._useMRU:
- self.bindEvent(dEvents.MenuOpen, self._onMenuOpenMRU)
-
- def __onWxMenuOpen(self, evt):
- if not self:
- return
- cap = self.Caption
- try:
- if evt.GetMenu().Caption == cap:
- # Opening a single menu will trigger the wx
event
- # for every menu in the menubar.
- self.raiseEvent(dEvents.MenuOpen, evt)
- else:
- evt.Skip()
- except AttributeError:
- evt.Skip()
-
-
- def __onWxMenuClose(self, evt):
- if not self:
- return
- cap = self.Caption
- try:
- if evt.GetMenu().Caption == cap:
- # Closing a single menu will trigger the wx
event
- # for every menu in the menubar.
- self.raiseEvent(dEvents.MenuClose, evt)
- else:
- evt.Skip()
- except AttributeError:
- evt.Skip()
-
-
def _onMenuOpenMRU(self, evt):
if self.Application:
self.Application.onMenuOpenMRU(self)
@@ -87,7 +48,10 @@
"""See self._setId(), which is where the binding of wxEvents
needs to take
place.
"""
+ self.bindEvent(dEvents.MenuOpen, self._onMenuHighlight)
self.bindEvent(dEvents.MenuHighlight, self._onMenuHighlight)
+ if self._useMRU:
+ self.bindEvent(dEvents.MenuOpen, self._onMenuOpenMRU)
def _onMenuHighlight(self, evt):
@@ -109,6 +73,9 @@
if de is not None:
if callable(de):
item.Enabled = de()
+
+ if isinstance(item, dMenu):
+ item._setDynamicEnabled()
def __onWxMenuHighlight(self, evt):
Modified: trunk/dabo/ui/uiwx/dPemMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dPemMixin.py 2008-08-27 21:28:29 UTC (rev 4472)
+++ trunk/dabo/ui/uiwx/dPemMixin.py 2008-08-27 22:43:18 UTC (rev 4473)
@@ -510,7 +510,8 @@
def __onWxMenuOpen(self, evt):
- self.raiseEvent(dEvents.MenuOpen, evt)
+ if evt.Menu:
+ evt.Menu.raiseEvent(dEvents.MenuOpen, evt)
def __onWxGotFocus(self, evt):
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/[EMAIL PROTECTED]