Virtual key mapping

Vadim Zeitlin vadim at wxwidgets.org
Tue May 6 10:32:28 PDT 2008


On Tue, 6 May 2008 08:11:15 -0700 (PDT) Marcin 'Malcom' Malich <malcompl at gmail.com> wrote:

MMM> But VK_APPS isn't mapped to WXK_MENU on Windows.
MMM> And this key code generating right mouse click event in WM_KEYDOWN/
MMM> WM_KEYUP,

 We could also generate a key event for it if mouse event is not processed
but it looked like a good idea at the time when this key was introduced
under Windows to provide automatic support for it in the existing code
which only handled right mouse clicks. Of course, using the same logic we
should generate wxContextMenuEvent for it [too?] and not wxMouseEvent...

MMM> so it makes problematic situation in handling context menu
MMM> on custom controlls when the event is generated form keyboard.

 You can distinguish the events generated from keyboard by checking if the
position is (-1, -1).

MMM> Why wx has no left and right version of shift/ctrl/alt?
MMM> Win, gtk and x generate this key code, and sometimes it is helpful.

 I don't know about X but Windows doesn't generate it. Quoting from
winuser.h:

/*
 * VK_L* & VK_R* - left and right Alt, Ctrl and Shift virtual keys.
 * Used only as parameters to GetAsyncKeyState() and GetKeyState().
 * No other API or message will distinguish left and right keys in this way.
 */

And, of course, changing shift key events into left/right shift ones
wouldn't be backwards-compatible so we'd need to generate both of them
which would be rather ugly. So the current solution of generating the same
event and then letting the applications which really need to distinguish
between them (which is a small minority after all) to use wxGetKeyState()
doesn't seem too bad to me. Of course, this might just prove that I'm too
warped by exposure to Win32 API...

 Regards,
VZ

-- 
TT-Solutions: wxWidgets consultancy and technical support
               http://www.tt-solutions.com/



More information about the wx-users mailing list