Update of /cvsroot/pythoncard/PythonCard/components
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15027/components
Modified Files:
button.py
Log Message:
ButtonMouseClickEvent test
added button driven by command to testevents sample
Index: button.py
===================================================================
RCS file: /cvsroot/pythoncard/PythonCard/components/button.py,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** button.py 21 Apr 2004 03:45:00 -0000 1.24
--- button.py 27 Apr 2004 02:43:33 -0000 1.25
***************
*** 8,15 ****
from PythonCard import event, widget
class ButtonSpec(widget.WidgetSpec):
def __init__(self):
! events = [event.MouseClickEvent]
attributes = {
'label':{'presence':'mandatory'},
--- 8,19 ----
from PythonCard import event, widget
+ ButtonEvents = [event.ButtonMouseClickEvent]
class ButtonSpec(widget.WidgetSpec):
def __init__(self):
! # KEA 2004-04-26
! # test to use new event classes
! events = ButtonEvents
! ## events = [event.MouseClickEvent]
attributes = {
'label':{'presence':'mandatory'},
***************
*** 83,88 ****
def bindEvent(self, aEventClass):
parent = self._component._parent
! if aEventClass is event.MouseClickEvent:
! wx.EVT_BUTTON(parent, self._component.GetId(), self._dispatch)
def _dispatch(self, aWxEvent):
--- 87,97 ----
def bindEvent(self, aEventClass):
parent = self._component._parent
! # KEA 2004-04-26
! # test to use new event classes
! if aEventClass is event.ButtonMouseClickEvent:
! event.ButtonMouseClickEvent.bindFunction(parent, self._component.GetId(), self._dispatch)
!
! ## if aEventClass is event.MouseClickEvent:
! ## wx.EVT_BUTTON(parent, self._component.GetId(), self._dispatch)
def _dispatch(self, aWxEvent):
***************
*** 96,105 ****
evt = None
! if aWxEvent.GetEventType() == wx.wxEVT_COMMAND_BUTTON_CLICKED:
! if component._getCommand() is not None:
! evt = event.CommandEvent(component._getCommand(), component)
! evt.setNativeEvent(aWxEvent)
! else:
! evt = self._createEvent(event.MouseClickEvent, aWxEvent)
if evt is not None:
--- 105,138 ----
evt = None
! # KEA 2004-04-26
! # test to use new event classes
! # this is a generic loop which because there is only
! # one event class in ButtonEvents is a little long-winded
! # as soon as we find a match we break out of the loop
! # if ButtonEvents was called ComponentSpecificEvents
! # or something generic then maybe this loop would be the same for
! # all components?
! # if we had a mapping of ids to event classes
! # then you could just use a try/except block and get the class
! # directly from the ButtonEvents list
! # eventClass = ButtonEvents[indexToClassMapping(eventType)]
! eventType = aWxEvent.GetEventType()
! for eventClass in ButtonEvents:
! if eventType == eventClass.id:
! if eventClass.command:
! if component._getCommand() is not None:
! evt = event.CommandEvent(component._getCommand(), component)
! evt.setNativeEvent(aWxEvent)
! else:
! evt = self._createEvent(eventClass, aWxEvent)
! else:
! evt = self._createEvent(eventClass, aWxEvent)
! break
! ## if aWxEvent.GetEventType() == wx.wxEVT_COMMAND_BUTTON_CLICKED:
! ## if component._getCommand() is not None:
! ## evt = event.CommandEvent(component._getCommand(), component)
! ## evt.setNativeEvent(aWxEvent)
! ## else:
! ## evt = self._createEvent(event.MouseClickEvent, aWxEvent)
if evt is not None:
|