def _dispatch(self, aWxEvent): eventType = aWxEvent.GetEventType() # TextField specific stuff # the question is how we either call the generic stuff above # due to the try/except blocks this code would probably # work in the generic event handling but that would be unclean <wink> if eventType == wx.wxEVT_SET_FOCUS: try: aWxEvent.GetEventObject().DiscardEdits() except: pass elif eventType == wx.wxEVT_KILL_FOCUS: try: aWxEvent.target = aWxEvent.GetEventObject() # only wxTextCtrl should have IsModified # so an exception will be thrown and the event won't be posted # for other components, but they shouldn't be binding to these # handlers anyway, so I'm just being overly defensive # same with DiscardEdits() above #modified = obj.IsModified() if not aWxEvent.target.IsBeingDeleted( ) and aWxEvent.target.IsModified(): #closeFieldEvent = aWxEvent.Clone() #closeFieldEvent.SetEventType(event.wxEVT_CLOSE_FIELD) # should I be using wx.PyEvent() instead? closeFieldEvent = wx.WindowCreateEvent() closeFieldEvent.SetEventType(wxEVT_CLOSE_FIELD) closeFieldEvent.SetEventObject(aWxEvent.target) closeFieldEvent.SetId(aWxEvent.GetId()) closeFieldEvent.SetTimestamp(aWxEvent.GetTimestamp()) # this is what Robin suggested instead, see: # http://aspn.activestate.com/ASPN/Mail/Message/wxPython-users/1103427 #obj.GetParent().GetEventHandler().ProcessEvent(closeFieldEvent) # KEA 2004-04-30 # ProcessEvent will cause closeField to occur before loseFocus and # gainFocus messages, so should we do a wxCallAfter instead? # in the case of fields should closeField be an InsteadOfTypeEvent # and replace the loseFocus event? probably not since they mean # different things aWxEvent.target.GetEventHandler().ProcessEvent( closeFieldEvent) #wx.PostEvent(obj.GetParent(), evt) #print 'posted closeField' except: pass # rest of the dispatch is standard widget.Widget._dispatch(self, aWxEvent)
def test_WindowCreateEvent_ctor(self): evt = wx.WindowCreateEvent()