From: Kevin A. <ka...@us...> - 2004-05-02 19:50:06
|
Update of /cvsroot/pythoncard/PythonCard/components In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21950/components Modified Files: button.py passwordfield.py textarea.py textfield.py Log Message: moved _binding and _dispatch into widget.py added component specific _binding to TextField, TextArea, PasswordField switched to wx.GetApp and wx.GetTopLevelwindow added binding and id attributes to background event classes added TextArea to testevents Index: textfield.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/textfield.py,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** textfield.py 1 May 2004 18:47:48 -0000 1.26 --- textfield.py 2 May 2004 19:49:57 -0000 1.27 *************** *** 103,107 **** #adapter = TextFieldEventBinding(self) #adapter.bindEvents() ! self._bindEvents() def _getAlignment(self): --- 103,107 ---- #adapter = TextFieldEventBinding(self) #adapter.bindEvents() ! self._bindEvents(event.WIDGET_EVENTS + TextFieldEvents) def _getAlignment(self): *************** *** 271,369 **** ClearAll = wx.TextCtrl.Clear ! def _bindEvents(self): ! # shouldn't components be subclasses of Scriptable? ! # components would have their own handlers but when ! # looking for a handler match it will search the parents ! # for now just grab handlers from the background ! background = self.GetParent().GetParent() ! ! # where should this check go? ! # should we just set a "global" in the app instance such as ! # self.stack.app.bindUnusedEvents ! # this kind of thing isn't going to work for Rowland's compound ! # components ! if background.stack.app._showDebugMenu: ! bindUnusedEvents = True ! else: ! bindUnusedEvents = False ! ! # helper variable to simplify test for whether to bind InsteadOfTypeEvents ! boundEvents = {} ! ! self.eventIdToHandler = {} ! self.wxEventIdMap = {} ! ! if 0: ! print "\nBINDING...", self.name ! #for eventClass in event.WIDGET_EVENTS + ButtonEvents: ! #for eventClass in ButtonEvents: ! for eventClass in event.WIDGET_EVENTS + TextFieldEvents: ! # need to figure out a way to avoid the need ! # for this id to class mapping which is used in _dispatch below ! self.wxEventIdMap[eventClass.id] = eventClass ! # command handler overrides normal mouseClick or select handler ! # so dispatch will automatically dispatch to the command handler ! # by looking up the handler this way ! # it also means that if there is a command association with this component ! # then the regular mouseClick or select handler will never be bound, just ignored ! if issubclass(eventClass, event.CommandTypeEvent) and self.command: ! handler = background.findHandler('on_' + self.command + '_command') ! if not handler: ! handler = background.findHandler('on_' + self.name + '_' + eventClass.name) ! else: ! handler = background.findHandler('on_' + self.name + '_' + eventClass.name) ! if not handler: ! handler = background.findHandler('on_' + eventClass.name) ! if handler or bindUnusedEvents: ! # only bind events that have an event handler ! # in this scenario unused events are never bound ! # which is more efficient, but the Message Watcher needs ! # to be changed ! # alternatively we can bind everything and then in _dispatch ! # if there isn't a match in eventIdToHandler then we know ! # the event isn't used and we can set used to False ! # the complication would be that we probably have to have to ! # always call Skip() which may or may not be a hassle with components ! ! # this doesn't bind command events ! # they would be of the form on_somename_command ! # or perhaps on_command but I don't think we would want ! # to support that ! # the event binding would be specific to a component ! # since on dispatch command overrides something like mouseClickEvent ! # but the name of the command is not related to the component ! # need to look at whether self.command has a value and then bind ! # with ButtonMouseClickEvent.binding if that isn't already bound ! # then in dispatch have to check again I think ! ! # need to avoid double binding ! # also binding shouldn't be order-specific ! # so how to avoid binding mouseDrag to _dispatch ! # if mouseMove is already bound or if binding mouseMove ! # not rebinding if mouseDrag is already bound ! # perhaps MouseDragEvent keeps a reference to MouseMoveEvent ! # and that is inserted into boundEvents, then we check boundEvents ! # prior to rebinding? ! if not boundEvents.get(eventClass.binding, None): ! self.Bind(eventClass.binding, self._dispatch) ! boundEvents[eventClass.binding] = eventClass.name ! if handler: ! if 0: ! print " binding", self.name, eventClass.name, handler._name, eventClass.id ! self.eventIdToHandler[eventClass.id] = handler ! ! # in order for closeField to work properly ! # both gainFocus and loseFocus have to be bound to _dispatch ! # regardless of whether they have handlers or not ! # everything else above is generic except the for statement ! # but that can be generalized once all components are bound ! # the same way ! for eventClass in [event.GainFocusEvent, event.LoseFocusEvent]: ! if not boundEvents.get(eventClass.binding, None): ! self.Bind(eventClass.binding, self._dispatch) ! boundEvents[eventClass.binding] = eventClass.name ! if 0: print "\n boundEvents:" --- 271,290 ---- ClearAll = wx.TextCtrl.Clear ! def _bindEvents(self, eventList): ! widget.Widget._bindEvents(self, eventList) ! # in order for closeField to work properly ! # both gainFocus and loseFocus have to be bound to _dispatch ! # regardless of whether they have handlers or not ! for eventClass in [event.GainFocusEvent, event.LoseFocusEvent]: ! if not self.boundEvents.get(eventClass.binding, None): ! self.Bind(eventClass.binding, self._dispatch) ! self.boundEvents[eventClass.binding] = eventClass.name + # calling widget.Widget._bindEvents after instead of before + # our component specific initialization would mean any log debug + # statements like this could just be in Widget_bindEvents + # however, until we convert all the components I'm not sure + # that changing the order will always work if 0: print "\n boundEvents:" *************** *** 375,510 **** print " ", id, self.eventIdToHandler[id]._function print "\n\n" - boundEvents = None - # this is pretty generic, but Button doesn't have any specific - # handling that is required so I need to do the same kind of code - # for TextField and see what the special handling for gainFocus, - # loseFocus, closeField will look like - # it probably won't need special handling for the key events def _dispatch(self, aWxEvent): eventType = aWxEvent.GetEventType() ! ! eventName = None ! ! if eventType == wx.wxEVT_TIMER: ! aWxEvent.interval = aWxEvent.GetInterval() ! # wxPython 2.5.1.5 workaround ! # for some reason wx.TimerEvent does not contain the event target ! # so we have to set it ourselves ! aWxEvent.target = aWxEvent.eventObject = self ! else: ! try: ! # all events should have GetEventObject() ! # except of course for wx.TimerEvent above ! # KEA 2004-04-25 ! # should we remove this redundant identifier? ! aWxEvent.target = aWxEvent.eventObject = self ! except: ! pass ! # Each of these could check the event class like ! # wxListEvent and wxTreeEvent above. try: ! # mouse and key events ! aWxEvent.position = tuple(aWxEvent.GetPosition()) ! aWxEvent.x = aWxEvent.GetX() ! aWxEvent.y = aWxEvent.GetY() ! aWxEvent.altDown = aWxEvent.AltDown() ! aWxEvent.controlDown = aWxEvent.ControlDown() ! aWxEvent.shiftDown = aWxEvent.ShiftDown() except: pass try: ! # key events ! aWxEvent.keyCode = aWxEvent.GetKeyCode() except: pass - if issubclass(self.wxEventIdMap[eventType], event.CommandTypeEvent): - # could be command, so need to report the name - # for the handler if it exists - if self.command: - eventName = 'command' - elif eventType == event.MouseMoveEvent.id: - # check to see if this is a mouseDrag - if aWxEvent.Dragging(): - eventType = event.MouseDragEvent.id - # don't need this if all event types have unique ids - #eventName = event.MouseDragEvent.name - - # 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.target.DiscardEdits() - except: - pass - elif eventType == wx.wxEVT_KILL_FOCUS: - try: - # only wxTextCtrl and wxRightTextCtrl 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 be overly defensive - # same with DiscardEdits() above - #modified = obj.IsModified() - if 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 - - - - if not eventName: - eventName = self.wxEventIdMap[eventType].name ! # it shouldn't be possible to be in _dispatch for an event ! # that wasn't bound above, but just in case... ! handler = self.eventIdToHandler.get(eventType, None) ! if handler: ! event.EventLog.getInstance().log(eventName, self.name, True) ! if 0: ! print "dispatching", handler._name ! # make a lowercase alias ! aWxEvent.skip = aWxEvent.Skip ! ! # the event handlers are part of the Background so ! # we have to have a reference to call the handler below ! background = self.GetParent().GetParent() ! ! # this is what is in event.py ! # aHandler.getFunction()( aOwner, self.getSource(), self ) ! handler.getFunction()(background, aWxEvent) ! ! # do we have to clean up this alias? ! aWxEvent.skip = None ! # how about this local reference to handler? ! handler = None ! background = None ! else: ! event.EventLog.getInstance().log(eventName, self.name, False) ! # hopefully this is all we need to do for "unused events" ! aWxEvent.Skip() - # cleanup - aWxEvent.target = aWxEvent.eventObject = None alignment = property(_getAlignment, _setAlignment) --- 296,348 ---- print " ", id, self.eventIdToHandler[id]._function print "\n\n" 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 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) alignment = property(_getAlignment, _setAlignment) *************** *** 514,635 **** - class TextFieldEventBinding( event.DefaultEventBinding ) : - """ - Bind the Events supported by event.TextField to wxPython. - """ - def __init__( self, aComponent ) : - - event.DefaultEventBinding.__init__( self, aComponent ) - - def bindEvent( self, aEventClass ) : - - parent = self._component._parent - - if aEventClass is event.CloseFieldEvent : - event.EVT_CLOSE_FIELD(parent, self._component.GetId(), self._dispatch) - - if aEventClass is event.TextUpdateEvent : - wx.EVT_TEXT( parent, self._component.GetId(), self._dispatch ) - - # KEA 2001-10-05 - # I don't think this event is used in TextField ?! - #if aEventClass is TextEnterEvent : - # EVT_TEXT_ENTER( parent, self._component.GetId(), self._dispatch ) - - if aEventClass is event.KeyDownEvent : - wx.EVT_KEY_DOWN( self._component, self._dispatch ) - - if aEventClass is event.KeyUpEvent : - wx.EVT_KEY_UP( self._component, self._dispatch ) - - if aEventClass is event.KeyPressEvent : - wx.EVT_CHAR( self._component, self._dispatch ) - - def _dispatch(self, aWxEvent): - # Call our superclass to dispatch the standard mouse - # events that every widget should get. - if event.DefaultEventBinding._dispatch(self, aWxEvent): - if (aWxEvent.GetEventType() == wx.wxEVT_SET_FOCUS): - try: - aWxEvent.GetEventObject().DiscardEdits() - except: - pass - - if (aWxEvent.GetEventType() == wx.wxEVT_KILL_FOCUS): - try: - obj = aWxEvent.GetEventObject() - # only wxTextCtrl and wxRightTextCtrl 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 be overly defensive - # same with DiscardEdits() above - #modified = obj.IsModified() - if obj.IsModified(): - #closeFieldEvent = aWxEvent.Clone() - #closeFieldEvent.SetEventType(event.wxEVT_CLOSE_FIELD) - # should I be using wx.PyEvent() instead? - closeFieldEvent = wx.WindowCreateEvent() - closeFieldEvent.SetEventType(event.wxEVT_CLOSE_FIELD) - closeFieldEvent.SetEventObject(aWxEvent.GetEventObject()) - 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) - obj.GetEventHandler().ProcessEvent(closeFieldEvent) - #wx.PostEvent(obj.GetParent(), evt) - #print 'posted closeField' - except: - pass - return - - evt = None - - if aWxEvent.GetEventType() == event.wxEVT_CLOSE_FIELD: - #print 'handling closeField' - evt = self._createEvent(event.CloseFieldEvent, aWxEvent) - - if aWxEvent.GetEventType() == wx.wxEVT_COMMAND_TEXT_UPDATED : - evt = self._createEvent( event.TextUpdateEvent, aWxEvent ) - - #if aWxEvent.GetEventType() == wxEVT_COMMAND_TEXT_ENTER : - # event = self._createEvent( TextEnterEvent, aWxEvent ) - # this should be associated with losing focus, not textEnter - #self._component.notifyEventListeners( CloseField( self._component ) ) - - if aWxEvent.GetEventType() == wx.wxEVT_KEY_DOWN : - #print '_dispatch wxEVT_KEY_DOWN' - #evt = KeyDownEvent( self._component ) - evt = self._createEvent( event.KeyDownEvent, aWxEvent ) - - if aWxEvent.GetEventType() == wx.wxEVT_KEY_UP : - #print '_dispatch wxEVT_KEY_UP' - #evt = KeyUpEvent( self._component ) - evt = self._createEvent( event.KeyUpEvent, aWxEvent ) - - if aWxEvent.GetEventType() == wx.wxEVT_CHAR : - #print '_dispatch wxEVT_CHAR' - #evt = KeyPressEvent( self._component ) - evt = self._createEvent( event.KeyPressEvent, aWxEvent ) - - if evt is not None : - #print '_dispatch evt is not None' - self._component.notifyEventListeners( evt ) - #print "after notify" - - # KEA 2001-10-05 - # there needs to be an Event.Skip() somewhere if the event was not handled - # by user code - # however, skip should normally only be called if the user code didn't process - # the event, which will allow the user code to "eat" the event, suppressing - # and/or changing the actions of certain keys - # need to make a complete list of which events can be eaten and which can't - if not evt.getUsed(): - aWxEvent.Skip() - # KEA 2001-10-26 - # if textEnter wasn't handled then focus should move to the next - # control in the panel, just like pressing tab - - import sys from PythonCard import registry --- 352,355 ---- Index: passwordfield.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/passwordfield.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** passwordfield.py 21 Apr 2004 16:34:31 -0000 1.19 --- passwordfield.py 2 May 2004 19:49:57 -0000 1.20 *************** *** 60,65 **** self.SetBackgroundColour(self.GetParent().GetBackgroundColour()) ! adapter = textfield.TextFieldEventBinding(self) ! adapter.bindEvents() --- 60,66 ---- self.SetBackgroundColour(self.GetParent().GetBackgroundColour()) ! #adapter = textfield.TextFieldEventBinding(self) ! #adapter.bindEvents() ! self._bindEvents(event.WIDGET_EVENTS + textfield.TextFieldEvents) Index: button.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/button.py,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** button.py 1 May 2004 18:47:48 -0000 1.28 --- button.py 2 May 2004 19:49:57 -0000 1.29 *************** *** 55,59 **** #adapter = ButtonEventBinding(self) #adapter.bindEvents() ! self._bindEvents() def _getDefault(self): --- 55,59 ---- #adapter = ButtonEventBinding(self) #adapter.bindEvents() ! self._bindEvents(event.WIDGET_EVENTS + ButtonEvents) def _getDefault(self): *************** *** 81,304 **** pass - def _bindEvents(self): - # shouldn't components be subclasses of Scriptable? - # components would have their own handlers but when - # looking for a handler match it will search the parents - # for now just grab handlers from the background - background = self.GetParent().GetParent() - - # where should this check go? - # should we just set a "global" in the app instance such as - # self.stack.app.bindUnusedEvents - # this kind of thing isn't going to work for Rowland's compound - # components - if background.stack.app._showDebugMenu: - bindUnusedEvents = True - else: - bindUnusedEvents = False - - # helper variable to simplify test for whether to bind InsteadOfTypeEvents - boundEvents = {} - - self.eventIdToHandler = {} - self.wxEventIdMap = {} - - if 0: - print "\nBINDING...", self.name - - for eventClass in event.WIDGET_EVENTS + ButtonEvents: - #for eventClass in ButtonEvents: - # need to figure out a way to avoid the need - # for this id to class mapping which is used in _dispatch below - self.wxEventIdMap[eventClass.id] = eventClass - # command handler overrides normal mouseClick or select handler - # so dispatch will automatically dispatch to the command handler - # by looking up the handler this way - # it also means that if there is a command association with this component - # then the regular mouseClick or select handler will never be bound, just ignored - if issubclass(eventClass, event.CommandTypeEvent) and self.command: - handler = background.findHandler('on_' + self.command + '_command') - if not handler: - handler = background.findHandler('on_' + self.name + '_' + eventClass.name) - else: - handler = background.findHandler('on_' + self.name + '_' + eventClass.name) - if not handler: - handler = background.findHandler('on_' + eventClass.name) - if handler or bindUnusedEvents: - # only bind events that have an event handler - # in this scenario unused events are never bound - # which is more efficient, but the Message Watcher needs - # to be changed - # alternatively we can bind everything and then in _dispatch - # if there isn't a match in eventIdToHandler then we know - # the event isn't used and we can set used to False - # the complication would be that we probably have to have to - # always call Skip() which may or may not be a hassle with components - - # this doesn't bind command events - # they would be of the form on_somename_command - # or perhaps on_command but I don't think we would want - # to support that - # the event binding would be specific to a component - # since on dispatch command overrides something like mouseClickEvent - # but the name of the command is not related to the component - # need to look at whether self.command has a value and then bind - # with ButtonMouseClickEvent.binding if that isn't already bound - # then in dispatch have to check again I think - - # need to avoid double binding - # also binding shouldn't be order-specific - # so how to avoid binding mouseDrag to _dispatch - # if mouseMove is already bound or if binding mouseMove - # not rebinding if mouseDrag is already bound - # perhaps MouseDragEvent keeps a reference to MouseMoveEvent - # and that is inserted into boundEvents, then we check boundEvents - # prior to rebinding? - if not boundEvents.get(eventClass.binding, None): - self.Bind(eventClass.binding, self._dispatch) - boundEvents[eventClass.binding] = eventClass.name - if handler: - if 0: - print " binding", self.name, eventClass.name, handler._name, eventClass.id - self.eventIdToHandler[eventClass.id] = handler - - if 0: - print "\n boundEvents:" - for name in boundEvents.values(): - print " ", name - print "\n\n" - print "\n self.eventIdToHandler:" - for id in self.eventIdToHandler: - print " ", id, self.eventIdToHandler[id]._function - print "\n\n" - boundEvents = None - - # this is pretty generic, but Button doesn't have any specific - # handling that is required so I need to do the same kind of code - # for TextField and see what the special handling for gainFocus, - # loseFocus, closeField will look like - # it probably won't need special handling for the key events - def _dispatch(self, aWxEvent): - eventType = aWxEvent.GetEventType() - - eventName = None - - if eventType == wx.wxEVT_TIMER: - aWxEvent.interval = aWxEvent.GetInterval() - # wxPython 2.5.1.5 workaround - # for some reason wx.TimerEvent does not contain the event target - # so we have to set it ourselves - aWxEvent.target = aWxEvent.eventObject = self - else: - try: - # all events should have GetEventObject() - # except of course for wx.TimerEvent above - # KEA 2004-04-25 - # should we remove this redundant identifier? - aWxEvent.target = aWxEvent.eventObject = self - except: - pass - # Each of these could check the event class like - # wxListEvent and wxTreeEvent above. - try: - # mouse and key events - aWxEvent.position = tuple(aWxEvent.GetPosition()) - aWxEvent.x = aWxEvent.GetX() - aWxEvent.y = aWxEvent.GetY() - aWxEvent.altDown = aWxEvent.AltDown() - aWxEvent.controlDown = aWxEvent.ControlDown() - aWxEvent.shiftDown = aWxEvent.ShiftDown() - except: - pass - try: - # key events - aWxEvent.keyCode = aWxEvent.GetKeyCode() - except: - pass - if issubclass(self.wxEventIdMap[eventType], event.CommandTypeEvent): - # could be command, so need to report the name - # for the handler if it exists - if self.command: - eventName = 'command' - elif eventType == event.MouseMoveEvent.id: - # check to see if this is a mouseDrag - if aWxEvent.Dragging(): - eventType = event.MouseDragEvent.id - # don't need this if all event types have unique ids - #eventName = event.MouseDragEvent.name - - # the component-specific helper attributes below - # should be handled in the relevant component _dispatch - # not the generic one - """ - if eventType in [wx.wxEVT_COMMAND_LIST_KEY_DOWN, - wx.wxEVT_COMMAND_TREE_KEY_DOWN]: - try: - # key events are different for wxTreeCtrl and wxListCtrl - aWxEvent.keyCode = aWxEvent.GetCode() - except: - pass - try: - # wxListEvent doesn't have GetKeyEvent for some reason - keyEvent = aWxEvent.GetKeyEvent() - aWxEvent.altDown = keyEvent.AltDown() - aWxEvent.controlDown = keyEvent.ControlDown() - aWxEvent.shiftDown = keyEvent.ShiftDown() - except: - pass - elif eventType in [wx.wxEVT_COMMAND_TREE_BEGIN_DRAG, \ - wx.wxEVT_COMMAND_TREE_BEGIN_RDRAG, \ - wx.wxEVT_COMMAND_TREE_END_DRAG, \ - wx.wxEVT_COMMAND_LIST_BEGIN_DRAG, \ - wx.wxEVT_COMMAND_LIST_BEGIN_RDRAG, \ - wx.wxEVT_COMMAND_LIST_COL_BEGIN_DRAG, \ - wx.wxEVT_COMMAND_LIST_COL_DRAGGING, \ - wx.wxEVT_COMMAND_LIST_COL_END_DRAG]: - try: - # The mouse position during a drag event - # there doesn't appear to be a way of getting the - # state of the shift, alt, and control keys - # during a mouse drag. - aWxEvent.position = tuple(aWxEvent.GetPoint()) - aWxEvent.x = aWxEvent.position[0] - aWxEvent.y = aWxEvent.position[1] - except: - pass - """ - - if not eventName: - eventName = self.wxEventIdMap[eventType].name - - # it shouldn't be possible to be in _dispatch for an event - # that wasn't bound above, but just in case... - handler = self.eventIdToHandler.get(eventType, None) - if handler: - event.EventLog.getInstance().log(eventName, self.name, True) - if 0: - print "dispatching", handler._name - # make a lowercase alias - aWxEvent.skip = aWxEvent.Skip - - # the event handlers are part of the Background so - # we have to have a reference to call the handler below - background = self.GetParent().GetParent() - - # this is what is in event.py - # aHandler.getFunction()( aOwner, self.getSource(), self ) - handler.getFunction()(background, aWxEvent) - - # do we have to clean up this alias? - aWxEvent.skip = None - # how about this local reference to handler? - handler = None - background = None - else: - event.EventLog.getInstance().log(eventName, self.name, False) - # hopefully this is all we need to do for "unused events" - aWxEvent.Skip() - - # cleanup - aWxEvent.target = aWxEvent.eventObject = None - default = property(_getDefault, _setDefault) --- 81,84 ---- Index: textarea.py =================================================================== RCS file: /cvsroot/pythoncard/PythonCard/components/textarea.py,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** textarea.py 21 Apr 2004 16:34:31 -0000 1.23 --- textarea.py 2 May 2004 19:49:57 -0000 1.24 *************** *** 57,60 **** --- 57,62 ---- self.SetBackgroundColour(self.GetParent().GetBackgroundColour()) + self._bindEvents(event.WIDGET_EVENTS + textfield.TextFieldEvents) + # KEA 2004-04-20 # wxPython 2.5.1.5 workaround |