WXK_COMMAND

29 views
Skip to first unread message

Christian K.

unread,
Sep 18, 2012, 10:26:23 PM9/18/12
to wxpytho...@lists.wxwidgets.org
Hi,

I am unable to check whether the command key is currently pressed using
wx.GetKeyState(wx.WXK_COMMAND) within an TREE_SEL_CHANGING handler.
The result is always False. What should I try instead?
This happens on Os X 10.8 running python 2.7 with wxpython 2.8.12.1

Regards, Christian

Mike Driscoll

unread,
Sep 19, 2012, 1:49:51 PM9/19/12
to wxpytho...@googlegroups.com, wxpytho...@lists.wxwidgets.org, ckk...@hoc.net
Hi,


You almost certainly need to catch EVT_CHAR to get that. If you're trying to create a shortcut key combo (i.e. CMD+K), then you'll want to look at creating an AcceleratorTable instead. See the following tutorials for more info:

 - http://www.blog.pythonlibrary.org/2009/08/29/wxpython-catching-key-and-char-events/
 - http://www.blog.pythonlibrary.org/2010/12/02/wxpython-keyboard-shortcuts-accelerators/

- Mike

Robin Dunn

unread,
Sep 19, 2012, 2:32:21 PM9/19/12
to wxpytho...@googlegroups.com
Try using wx.GetMouseState instead. Although it is mostly about the
mouse position and button states it does include methods and properties
for the keyboard modifier keys as well. I don't remember about 2.8 for
sure but it does correctly report shift, ctrl, cmd, and alt for
wxOSX-cocoa 2.9.


--
Robin Dunn
Software Craftsman
http://wxPython.org

Christian K.

unread,
Sep 29, 2012, 7:54:09 AM9/29/12
to wxpytho...@lists.wxwidgets.org
Am 19.09.12 15:32, schrieb Robin Dunn:
Thanks! This works with both 2.8 and 2.9.

Christian


Reply all
Reply to author
Forward
0 new messages