Changeset 1854

Show
Ignore:
Timestamp:
01/24/2006 03:00:48 PM (3 years ago)
Author:
paul
Message:

Fixed dApp to raise the Activate/Deactivate events properly. Fixed dApp to raise Key events. The app gets key events if no window has stopped the event along the way. So now we can dApp.bindEvent(dEvents.KeyChar?, func). Fixed dApp to autoBindEvents().

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/dabo/dApp.py

    r1804 r1854  
    107107            self.setup() 
    108108        self._afterInit() 
     109        self.autoBindEvents() 
    109110         
    110111 
  • trunk/dabo/dEvents.py

    r1844 r1854  
    159159class KeyEvent(Event): 
    160160    def appliesToClass(eventClass, objectClass): 
    161         return issubclass(objectClass, dabo.ui.dPemMixin
     161        return issubclass(objectClass, (dabo.ui.dPemMixin, dabo.dApp)
    162162    appliesToClass = classmethod(appliesToClass) 
    163163     
  • trunk/dabo/ui/uiwx/uiApp.py

    r1839 r1854  
    1313        wx.App.__init__(self, 0, args) 
    1414        dObject.__init__(self) 
    15         self.Bind(wx.EVT_ACTIVATE_APP, self._onWxActivate) 
    1615         
    1716        self.Name = _("uiApp") 
     
    3736 
    3837    def setup(self, dApp): 
     38        self.dApp = dApp 
     39 
    3940        # wx has properties for appName and vendorName, so Dabo should update 
    4041        # these. Among other possible uses, I know that on Win32 wx will use 
     
    4445        self.SetVendorName(dApp.getAppInfo("vendorName")) 
    4546         
     47        self.Bind(wx.EVT_ACTIVATE_APP, self._onWxActivate) 
     48        self.Bind(wx.EVT_KEY_DOWN, self._onWxKeyDown) 
     49        self.Bind(wx.EVT_KEY_UP, self._onWxKeyUp) 
     50        self.Bind(wx.EVT_CHAR, self._onWxKeyChar) 
     51 
    4652        self.charset = "unicode" 
    4753        if not self.charset in wx.PlatformInfo: 
     
    6268        wx.InitAllImageHandlers() 
    6369 
    64         self.dApp = dApp 
    65      
    6670        frm = dApp.MainForm 
    6771        if frm is None: 
     
    104108        return self._platform 
    105109         
     110 
    106111    def _onWxActivate(self, evt): 
    107112        """ Raise the Dabo Activate or Deactivate appropriately.""" 
    108113        if bool(evt.GetActive()): 
    109             self.raiseEvent(dEvents.Activate, evt) 
     114            self.dApp.raiseEvent(dEvents.Activate, evt) 
    110115        else: 
    111             self.raiseEvent(dEvents.Deactivate, evt) 
     116            self.dApp.raiseEvent(dEvents.Deactivate, evt) 
    112117        evt.Skip() 
    113              
    114      
     118     
     119    def _onWxKeyChar(self, evt): 
     120        self.dApp.raiseEvent(dEvents.KeyChar, evt) 
     121        evt.Skip() 
     122             
     123    def _onWxKeyDown(self, evt): 
     124        self.dApp.raiseEvent(dEvents.KeyDown, evt) 
     125        evt.Skip() 
     126             
     127    def _onWxKeyUp(self, evt): 
     128        self.dApp.raiseEvent(dEvents.KeyUp, evt) 
     129        evt.Skip() 
     130             
     131 
    115132    def onWinClose(self, evt): 
    116133        """Close the topmost window, if any."""