]> granicus.if.org Git - python/commitdiff
Default waittime in the eventloop is now None. At low level it will then be set to...
authorJack Jansen <jack.jansen@cwi.nl>
Thu, 8 Mar 2001 23:10:37 +0000 (23:10 +0000)
committerJack Jansen <jack.jansen@cwi.nl>
Thu, 8 Mar 2001 23:10:37 +0000 (23:10 +0000)
Mac/Lib/FrameWork.py
Mac/Tools/IDE/Wapplication.py

index 4454c670216146d494436f8921af8fb56c7880fc..8a2ef17e960fe6b0a78b981bf7303859003720fb 100644 (file)
@@ -144,12 +144,11 @@ class Application:
        # event type.
        # Normally, however, you'd just define handlers for individual
        # events.
-       # (XXX I'm not sure if using default parameter values is the right
-       # way to define the mask and wait time passed to WaitNextEvent.)
        
        schedparams = (0, 0)    # By default disable Python's event handling
+       default_wait = None             # By default we wait GetCaretTime in WaitNextEvent
        
-       def mainloop(self, mask = everyEvent, wait = 0):
+       def mainloop(self, mask = everyEvent, wait = None):
                self.quitting = 0
                saveparams = apply(MacOS.SchedParams, self.schedparams)
                try:
@@ -169,7 +168,7 @@ class Application:
                while self.do1event(mask, wait=0):
                        pass
        
-       def do1event(self, mask = everyEvent, wait = 0):
+       def do1event(self, mask = everyEvent, wait = None):
                ok, event = self.getevent(mask, wait)
                if IsDialogEvent(event):
                        if self.do_dialogevent(event):
@@ -182,10 +181,14 @@ class Application:
        def idle(self, event):
                pass
        
-       def getevent(self, mask = everyEvent, wait = 0):
+       def getevent(self, mask = everyEvent, wait = None):
                if self.needmenubarredraw:
                        DrawMenuBar()
                        self.needmenubarredraw = 0
+               if wait is None:
+                       wait = self.default_wait
+                       if wait is None:
+                               wait = GetCaretTime()
                ok, event = WaitNextEvent(mask, wait)
                return ok, event
                        
index ae238a926dd888d851a6043c08af1c2438a90dba..88c415ce530094c9f80f7fff5c65a513196ec97d 100644 (file)
@@ -24,7 +24,7 @@ class Application(FrameWork.Application):
                # map certain F key codes to equivalent command-letter combos (JJS)
                self.fkeymaps = {122:"z", 120:"x", 99:"c", 118:"v"}
        
-       def mainloop(self, mask=FrameWork.everyEvent, wait=0):
+       def mainloop(self, mask=FrameWork.everyEvent, wait=None):
                import W
                self.quitting = 0
                saveyield = MacOS.EnableAppswitch(-1)
@@ -44,7 +44,7 @@ class Application(FrameWork.Application):
                finally:
                        MacOS.EnableAppswitch(1)
        
-       def debugger_mainloop(self, mask=FrameWork.everyEvent, wait=0):
+       def debugger_mainloop(self, mask=FrameWork.everyEvent, wait=None):
                import W
                self.debugger_quitting = 0
                saveyield = MacOS.EnableAppswitch(-1)