summaryrefslogtreecommitdiffstats
path: root/Mac/Lib
diff options
context:
space:
mode:
authorJack Jansen <jack.jansen@cwi.nl>1997-06-20 16:24:24 (GMT)
committerJack Jansen <jack.jansen@cwi.nl>1997-06-20 16:24:24 (GMT)
commitd080eddf8e796b33b874bba37ba9084a299a94ef (patch)
tree4abc28a5f9596addccd8c97752dd5578f4622f7a /Mac/Lib
parent3f5aef7fef27dbe4333feb16800ce6ab263ffb0b (diff)
downloadcpython-d080eddf8e796b33b874bba37ba9084a299a94ef.zip
cpython-d080eddf8e796b33b874bba37ba9084a299a94ef.tar.gz
cpython-d080eddf8e796b33b874bba37ba9084a299a94ef.tar.bz2
Added dopendingevents call
Added asyncevents call to enable asynchronous event handling
Diffstat (limited to 'Mac/Lib')
-rw-r--r--Mac/Lib/FrameWork.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/Mac/Lib/FrameWork.py b/Mac/Lib/FrameWork.py
index caaf81c..fc643e4 100644
--- a/Mac/Lib/FrameWork.py
+++ b/Mac/Lib/FrameWork.py
@@ -95,6 +95,7 @@ class Application:
"Application framework -- your application should be a derived class"
def __init__(self, nomenubar=0):
+ self._doing_asyncevents = 0
self.quitting = 0
self.needmenubarredraw = 0
self._windows = {}
@@ -102,6 +103,11 @@ class Application:
self.menubar = None
else:
self.makemenubar()
+
+ def __del__(self):
+ if self._doing_asyncevents:
+ self._doing_asyncevents = 0
+ MacOS.SetEventHandler()
def makemenubar(self):
self.menubar = MenuBar(self)
@@ -158,6 +164,11 @@ class Application:
schedparams = MacOS.SchedParams()
+ def dopendingevents(self, mask = everyEvent):
+ """dopendingevents - Handle all pending events"""
+ while self.do1event(mask, wait=0):
+ pass
+
def do1event(self, mask = everyEvent, wait = 0):
ok, event = self.getevent(mask, wait)
if IsDialogEvent(event):
@@ -179,6 +190,11 @@ class Application:
return ok, event
def dispatch(self, event):
+ # The following appears to be double work (already done in do1event)
+ # but we need it for asynchronous event handling
+ if IsDialogEvent(event):
+ if self.do_dialogevent(event):
+ return
(what, message, when, where, modifiers) = event
if eventname.has_key(what):
name = "do_" + eventname[what]
@@ -190,6 +206,21 @@ class Application:
handler = self.do_unknownevent
handler(event)
+ def asyncevents(self, onoff):
+ """asyncevents - Set asynchronous event handling on or off"""
+ old = self._doing_asyncevents
+ if old:
+ MacOS.SetEventHandler()
+ apply(MacOS.SchedParams, self.schedparams)
+ if onoff:
+ MacOS.SetEventHandler(self.dispatch)
+ doint, dummymask, benice, howoften, bgyield = \
+ self.schedparams
+ MacOS.SchedParams(doint, everyEvent, benice,
+ howoften, bgyield)
+ self._doing_asyncevents = onoff
+ return old
+
def do_dialogevent(self, event):
gotone, window, item = DialogSelect(event)
if gotone: