diff options
author | Jack Jansen <jack.jansen@cwi.nl> | 1998-10-15 15:29:16 (GMT) |
---|---|---|
committer | Jack Jansen <jack.jansen@cwi.nl> | 1998-10-15 15:29:16 (GMT) |
commit | 341d1fe18ea57443a19025472a88a0f285224e7a (patch) | |
tree | 4543689ba6c0dc2ee1f006bf46fd48ac33799ed2 | |
parent | 99d3c48772a2980e47b75659e98ea171bedd79ac (diff) | |
download | cpython-341d1fe18ea57443a19025472a88a0f285224e7a.zip cpython-341d1fe18ea57443a19025472a88a0f285224e7a.tar.gz cpython-341d1fe18ea57443a19025472a88a0f285224e7a.tar.bz2 |
For submenus remember the parent and parent index, so we can grey out our
entry if the menu is disabled. This does create a circular reference, so cleanup
becomes more important.
-rw-r--r-- | Mac/Lib/FrameWork.py | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/Mac/Lib/FrameWork.py b/Mac/Lib/FrameWork.py index 866b869..7d93ccb 100644 --- a/Mac/Lib/FrameWork.py +++ b/Mac/Lib/FrameWork.py @@ -518,6 +518,7 @@ class Menu: self.id, self.menu = self.bar.addmenu(title, after) bar.menus[self.id] = self self.items = [] + self._parent = None def delete(self): self.bar.delmenu(self.id) @@ -526,6 +527,7 @@ class Menu: del self.items del self.menu del self.id + del self._parent def additem(self, label, shortcut=None, callback=None, kind=None): self.menu.AppendMenu('x') # add a dummy string @@ -556,6 +558,8 @@ class Menu: sub = Menu(self.bar, title, -1) item = self.additem(label, '\x1B', None, 'submenu') self.menu.SetItemMark(item, sub.id) + sub._parent = self + sub._parent_item = item return sub def dispatch(self, id, item, window, event): @@ -587,8 +591,12 @@ class Menu: def enable(self, onoff): if onoff: self.menu.EnableItem(0) + if self._parent: + self._parent.menu.EnableItem(self._parent_item) else: self.menu.DisableItem(0) + if self._parent: + self._parent.menu.DisableItem(self._parent_item) if self.bar and self.bar.parent: self.bar.parent.needmenubarredraw = 1 |