summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>2002-08-29 22:04:15 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>2002-08-29 22:04:15 (GMT)
commitf21b7063d387c187dc872bf833db09a81f157ab2 (patch)
treecbb572ec4c6f19e48777540cb45f03cce2082299
parent983258ed7e96897e00c7a4459034d83816018181 (diff)
downloadcpython-f21b7063d387c187dc872bf833db09a81f157ab2.zip
cpython-f21b7063d387c187dc872bf833db09a81f157ab2.tar.gz
cpython-f21b7063d387c187dc872bf833db09a81f157ab2.tar.bz2
Added support for the help menu. Application.gethelpmenu() will return
it. Also fixed menu IDs to be signed in do_menudispatch. this is an incompatible change, but I don't think it'll hurt anyone.
-rw-r--r--Mac/Lib/FrameWork.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/Mac/Lib/FrameWork.py b/Mac/Lib/FrameWork.py
index b3bf55f..21a4f0e 100644
--- a/Mac/Lib/FrameWork.py
+++ b/Mac/Lib/FrameWork.py
@@ -13,6 +13,7 @@ from Carbon.Dlg import *
from Carbon.Dialogs import *
from Carbon.Evt import *
from Carbon.Events import *
+from Carbon.Help import *
from Carbon.Menu import *
from Carbon.Menus import *
from Carbon.Qd import *
@@ -111,6 +112,7 @@ class Application:
self.menubar = None
else:
self.makemenubar()
+ self._helpmenu = None
def __del__(self):
if self._doing_asyncevents:
@@ -125,6 +127,11 @@ class Application:
def makeusermenus(self):
self.filemenu = m = Menu(self.menubar, "File")
self._quititem = MenuItem(m, "Quit", "Q", self._quit)
+
+ def gethelpmenu(self):
+ if self._helpmenu == None:
+ self._helpmenu = HelpMenu(self.menubar)
+ return self._helpmenu
def _quit(self, *args):
self.quitting = 1
@@ -297,6 +304,8 @@ class Application:
(what, message, when, where, modifiers) = event
result = MenuSelect(where)
id = (result>>16) & 0xffff # Hi word
+ if id >= 0x8000:
+ id = -65536 + id
item = result & 0xffff # Lo word
self.do_rawmenu(id, item, window, event)
@@ -715,6 +724,18 @@ class AppleMenu(Menu):
elif MacOS.runtimemodel == 'ppc':
name = self.menu.GetMenuItemText(item)
OpenDeskAcc(name)
+
+class HelpMenu(Menu):
+ def __init__(self, bar):
+ # Note we don't call Menu.__init__, we do the necessary things by hand
+ self.bar = bar
+ self.menu, index = HMGetHelpMenu()
+ self.id = self.menu.GetMenuID()
+ bar.menus[self.id] = self
+ # The next line caters for the entries the system already handles for us
+ self.items = [None]*(index-1)
+ self._parent = None
+
class Window:
"""A single window belonging to an application"""
@@ -1066,6 +1087,9 @@ class TestApp(Application):
self.opt2 = CheckItem(mm, "Being hit on the head lessons", (kMenuOptionModifier, "A"))
self.opt3 = CheckItem(mm, "Complaints", (kMenuOptionModifier|kMenuNoCommandModifier, "A"))
Separator(m)
+ self.itemeh = MenuItem(m, "Enable Help", None, self.enablehelp)
+ self.itemdbg = MenuItem(m, "Debug", None, self.debug)
+ Separator(m)
self.quititem = MenuItem(m, "Quit", "Q", self.quit)
def save(self, *args):
@@ -1073,6 +1097,17 @@ class TestApp(Application):
def quit(self, *args):
raise self
+
+ def enablehelp(self, *args):
+ hm = self.gethelpmenu()
+ self.nohelpitem = MenuItem(hm, "There isn't any", None, self.nohelp)
+
+ def nohelp(self, *args):
+ print "I told you there isn't any!"
+
+ def debug(self, *args):
+ import pdb
+ pdb.set_trace()
def test():