Suspending accelerator processing inside wx.TextCtrl

30 views
Skip to first unread message

James Scholes

unread,
Apr 13, 2017, 8:21:24 PM4/13/17
to wxpytho...@googlegroups.com
Hi folks,

Just a quick question: I have an accelerator table set for my
application's main panel, and the shortcuts in it should be active
pretty much everywhere in the program. But they include some keystrokes
that are usually reserved for moving the cursor and selecting text
inside text fields (Ctrl+Left/Right for moving by word, Shift+Left/Right
for text selection).

How can I suspend processing of those accelerators while inside a
TextCtrl so that they carry out their normal functions? I tried setting
an accelerator table for the TextCtrl itself, and doing an event.Skip()
inside the wx.EVT_MENU handler. While this does prevent the keys from
triggering their panel-wide functions, they don't actually do what
they're supposed to do either. E.g. Ctrl+Left doesn't move by word, it
just leaves the cursor where it is.

Unsetting the accelerator table on focus seems like a bad idea, and
wouldn't work very well here as there are other shortcuts registered on
the table which should do something no matter the focused control type

Thanks in advance for any suggestions.
--
James Scholes
http://twitter.com/JamesScholes

James Scholes

unread,
Apr 19, 2017, 6:07:59 AM4/19/17
to wxpytho...@googlegroups.com
Hi folks,

Just a quick question: I have an accelerator table set for my
application's main panel, and the shortcuts in it should be active
pretty much everywhere in the program. But they include some keystrokes
that are usually reserved for moving the cursor and selecting text
inside text fields (Ctrl+Left/Right for moving by word, Shift+Left/Right
for text selection).

How can I suspend processing of those accelerators while inside a
TextCtrl so that they carry out their normal functions? I tried setting
an accelerator table for the TextCtrl itself, and doing an event.Skip()
inside the wx.EVT_MENU handler. I also tried setting the accelerator
table for the TextCtrl to an instance of wx.NullAcceleratorTable. While
this does prevent the keys from triggering their panel-wide functions,
they don't actually do what they're supposed to do either. E.g.
Ctrl+Left doesn't move by word, it just leaves the cursor where it is.

Reply all
Reply to author
Forward
0 new messages