global key bindings, wx.EVT_CHAR

Hi,

in a wx.App i use some frames (that i derived from wx.Frame and that 'know'
the application).

I want to handle all key events (or at least a large selection) globally.

As the single frames 'know' the application they stem from it is no problem
to forward events from all frames to the application.

But all the focus handling and existing bindings are quite a problem,
it is not sufficient to bind wx.EVT_CHAR to the frame, a panel in there
or any other container.

The frames i use contain other controls, buttons, sliders, radio buttons,
but mostly no TextCtrls.

Can anybody give me some hint on how to handle _all_ keys globally within
the application?

Or else, how is global key handling like Ctrl-Q => Quit, Ctrl-S => Save, ...
possible?

One more question, what is the preferred method to detect Ctrl-Key?
event.GetKeyCode() returns a 0x01 for Ctrl-A but there is no constant
defined for that.

Thanks for any hints,
Torsten.

Hello,

Hi,

in a wx.App i use some frames (that i derived from wx.Frame and that 'know'
the application).

I want to handle all key events (or at least a large selection) globally.

As the single frames 'know' the application they stem from it is no problem
to forward events from all frames to the application.

But all the focus handling and existing bindings are quite a problem,
it is not sufficient to bind wx.EVT_CHAR to the frame, a panel in there
or any other container.

The frames i use contain other controls, buttons, sliders, radio buttons,
but mostly no TextCtrls.

Can anybody give me some hint on how to handle _all_ keys globally within
the application?

Or else, how is global key handling like Ctrl-Q => Quit, Ctrl-S => Save, ...
possible?

Look at the AcceleratorTable class.

One more question, what is the preferred method to detect Ctrl-Key?
event.GetKeyCode() returns a 0x01 for Ctrl-A but there is no constant
defined for that.

KeyEvent.ControlDown() or KeyEvent.CmdDown()

Cody

···

On Aug 17, 2008, at 10:58 AM, Torsten Mohr wrote:

Take a look at http://lists.wxwidgets.org/pipermail/wxpython-users/2008-August/079006.html, and write back if this doesn’t do what you need it to.

Hello,

thank you all for the hint regarding wx.AcceleratorTable.

It looks like exactly what i was looking for. I haven't yet tested it but i'm
confident it'll work.

Best Regards,
Torsten.

···

Am Sonntag, 17. August 2008 19:43 schrieb mercado mercado:

Take a look at
http://lists.wxwidgets.org/pipermail/wxpython-users/2008-August/079006.html
, and write back if this doesn't do what you need it to.

  1. AFAIK, in wxPython, differently from Visual Basic, wx.Frame and wx.Panel DO NOT handle key events, and the same applies to all other widgets except wx.TextCtrl (surely) and wx.ComboBox (probably). A sure way I know to globally handle Ctrl-Q => Quit, Ctrl-S => Save and so forth isto combine menus and accelerators.
  2. To detect Ctrl-Key use GetModifiers()
···

2008/8/17 Torsten Mohr tmohr@s.netic.de

Hi,

in a wx.App i use some frames (that i derived from wx.Frame and that ‘know’

the application).

I want to handle all key events (or at least a large selection) globally.

As the single frames ‘know’ the application they stem from it is no problem

to forward events from all frames to the application.

But all the focus handling and existing bindings are quite a problem,

it is not sufficient to bind wx.EVT_CHAR to the frame, a panel in there

or any other container.

The frames i use contain other controls, buttons, sliders, radio buttons,

but mostly no TextCtrls.

Can anybody give me some hint on how to handle all keys globally within

the application?

Or else, how is global key handling like Ctrl-Q => Quit, Ctrl-S => Save, …

possible?

One more question, what is the preferred method to detect Ctrl-Key?

event.GetKeyCode() returns a 0x01 for Ctrl-A but there is no constant

defined for that.

Thanks for any hints,

Torsten.


wxpython-users mailing list

wxpython-users@lists.wxwidgets.org

http://lists.wxwidgets.org/mailman/listinfo/wxpython-users