From: Kevin A. <al...@se...> - 2001-12-04 00:01:41
|
Some clarifications... All events still go through a dispatcher. This way we can support event 'listeners' like the Message Watcher. It also allows us to bind some events such as a mouse drag that are not explicitly defined in wxPython. We will continue to use the simple event names already defined in spec.py such as 'mouseClick', 'mouseDown', 'keyPress', etc. rather than using the wxPython event macro names like wxEVT_COMMAND_BUTTON_CLICKED and wxEVT_COMMAND_CHECKBOX_CLICKED; both of those macro names refer to a mouse click in a control but different names are used in wxWindows/wxPython for different controls. At some point, we will document the mapping of PythonCard names to wxPython names for those people that need to debug some complex wxPython logic or mix direct wxPython event bindings and those going through the PythonCard dispatcher. The event name list will be expanded as we start supporting more wxPython event types. In addition, event handlers will continue to get the event source as the second argument of the handler since that has proven to be very convenient. These are some of the ways PythonCard hopefully simplifies the use of wxPython events. ka > -----Original Message----- > From: pyt...@li... > [mailto:pyt...@li...]On Behalf Of Kevin > Altis > Sent: Monday, December 03, 2001 3:17 PM > To: pythoncard-Users > Subject: [Pythoncard-users] native wxPython events checked in > > > cvs now has a slightly modified event dispatch that always sends native > wxPython events to handlers. This impacted the following samples: > dbBrowser, > doodle, resourceEditor, textEditor, textRouter, and widgets. All > occurances > of skip() (lowercase) were changed to Skip() and getNativeEvent() is no > longer used, since the native wxPython event info is now > available directly. > For example, here is the code in textRouter prior to the change: > > def on_area1_keyPress(self, target, event): > nEvent = event.getNativeEvent() > if nEvent.GetKeyCode() == 9: > target.replaceSelection("\t") > else: > event.skip() > > Here's the new version: > > def on_area1_keyPress(self, target, event): > if event.GetKeyCode() == 9: > target.replaceSelection("\t") > else: > event.Skip() > > The event being sent for keyPress is a wxKeyEvent, so you can look at the > wxWindows/wxPython docs to see the properties and methods of the > wxKeyEvent > class. Here are the docs for GetKeyCode: > > > "wxKeyEvent::GetKeyCode > int GetKeyCode() const > > Returns the virtual key code. ASCII events return normal ASCII > values, while > non-ASCII events return values such as WXK_LEFT for the left > cursor key. See > Keycodes for a full list of the virtual key codes." > > > Most of the time, a PythonCard handler doesn't need to access the event > directly, which is why so few samples were impacted. Most of the handlers > that did need to be fixed were dealing with key presses or tracking the > mouse location during a mouse move or drag event. You can do > diffs in cvs if > you need to see detailed changes. > > ka |