WXK_COMMAND

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

Hi,

···

On Tuesday, September 18, 2012 9:26:38 PM UTC-5, Christian K. wrote:

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

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:

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.

···

On 9/18/12 7:26 PM, Christian K. wrote:

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

--
Robin Dunn
Software Craftsman

Thanks! This works with both 2.8 and 2.9.

Christian

···

Am 19.09.12 15:32, schrieb Robin Dunn:

On 9/18/12 7:26 PM, Christian K. wrote:

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

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.