Confused about GetKeyCode()/GetUnicodeKey()

Vadim Zeitlin vadim at wxwidgets.org
Sat Nov 3 11:56:41 PDT 2007


On Sat, 3 Nov 2007 15:31:03 +0000 Richard Danter <radanter at googlemail.com> wrote:

RD> I am trying to write a keyboard event handler and I am a little
RD> confused which method I should use to get the key code. I think I
RD> should use GetUnicodeKey() since I have a Unicode build,

 This rather works in the other direction -- if you a Unicode build, you
may use GetUnicodeKey() to get key presses for non-ASCII characters. But
nothing prevents you from using GetKeyCode() to handle arrow keys.

RD> For the most part I can use GetKeyCode() OK, but I lose the ability to
RD> enter the Euro symbol (AltGr+4 on my UK keyboard), which works fine if
RD> I use GetUnicodeKey().

 I'm not sure about what does GetKeyCode() return for the Euro key but
normally you should simply check for the special WXK_XXX values first using
GetKeyCode() and if there is no match use GetUnicodeKey() to get the key
value.

 Regards,
VZ

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





More information about the wx-users mailing list