Roger Mayes wrote:
I'm using..
python 2.4.1
wxPython 2.6.1.0
Gentoo Linux 2.6.13-ck3 (con kolivas patch set)
gcc-3.3.6
gtk+-2.6.8
Windows XP Pro 5.1 service pack 1On Windows, for me, event.GetKeyCode() returns these values for these
keys:
In a EVT_KEY_* event or a EVT_CHAR event?
page up - 312
page down - 313
numpad page up - 312
numpad page down - 313On Linux, event.GetKeyCode() returns these values:
page up - 312
page down - 313
numpad page up - 382
numpad page up - 384While the definitions in both places appear to be:
wx.WXK_PRIOR - 312
wx.WXK_NEXT - 313
wx.WXK_PAGEUP - 368 wx.WXK_PAGEDOWN - 369
wx.WXK_NUMPAD_PAGEUP - 383
wx.WXK_NUMPAD_PAGEDOWN - 385
Don't forget about the WXK_NUMPAD_PRIOR and WXK_NUMPAD_NEXT. I'm not sure why we have both the PAGEUP/PAGEDOWN and the PRIOR/NEXT variants, perhaps it is for platforms that can have both sets on the keyboard...
Questions:
- Why would event.GetKeyCode() return values different from the
definitions?
Just think of PRIOR and NEXT as being variants of PAGEUP and PAGEDOWN that have the same meaning.
- What is the recommended way to detect numpad page up and numpad page
down on Linux?
I get WXK_NUMPAD_PRIOR and WXK_NUMPAD_NEXT in the EVT_KEY_* events.
- Is there any way to differentiate between page up and numpad page up
on Windows?
It works here. I get WXK_NUMPAD_PRIOR for the numpad pgup.
- Is there a way to find out the actual device scancode associated
with a key down or key up event?
The GetRawKeyCode may give it to you, depending on platform. That field is basically reserved for some platform specific value for the event.
Comments:
In years past, I've done assembler language work, sometimes inserting
or appending my own interrupt service routines into the chains of them,
and other times just making operating system calls to access structures
maintained by the operating system's interrupt service routines and so
forth. I've also done work (I hate to admit it here, but it's true) in C
on Windows, working with Win32, MFC, and eventually DirectX, etc. These
codes returned by event.GetKeyCode() don't appear to bare any
resemblance, so far as I can tell, to the scancodes that keyboard sends
to the computer or even to the cooked key codes that would be imbedded
Windows messages (I don't think? Am I wrong?) so they must be a function
of wx-widgets?
wxWidgets has an enum of all the WXK_* values, which is just turned into a sequence of integer values by the compiler. Each platform has a function that is called for the key/char events that maps the native value to one of these generic values. So, for example, wxMSW has a function in src/msw/window.cpp that maps the VK_* constants to a WXK_* value.
ยทยทยท
--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!