|
From: Kevin A. <al...@se...> - 2001-12-03 23:14:38
|
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
|