wxAcceleratorEntry intercepts keys in wxTextCtrl

12 views
Skip to first unread message

Andreas Falkenhahn

unread,
Feb 26, 2021, 9:05:52 AM2/26/21
to wx-u...@googlegroups.com
I'm listening to the SPACE and the left and right cursor keys using a wxAcceleratorTable. Now when my wxTextCtrl has the focus, it doesn't receive space or the left and right cursor keys any longer. Instead, the accelerators are triggered.

Is there any way to make the accelerators only trigger when the wxTextCtrl doesn't have the focus so that it is still possible to use space and the cursor keys in the wxTextCtrl even though there's an accelerator on them as well?

--
Best regards,
Andreas Falkenhahn mailto:and...@falkenhahn.com

Vadim Zeitlin

unread,
Feb 26, 2021, 4:59:51 PM2/26/21
to wx-u...@googlegroups.com
On Fri, 26 Feb 2021 15:06:24 +0100 Andreas Falkenhahn wrote:

AF> I'm listening to the SPACE and the left and right cursor keys using a
AF> wxAcceleratorTable. Now when my wxTextCtrl has the focus, it doesn't
AF> receive space or the left and right cursor keys any longer. Instead,
AF> the accelerators are triggered.
AF>
AF> Is there any way to make the accelerators only trigger when the
AF> wxTextCtrl doesn't have the focus so that it is still possible to use
AF> space and the cursor keys in the wxTextCtrl even though there's an
AF> accelerator on them as well?

In wxMSW you can override MSWShouldPreProcessMessage() in your
wxTextCtrl-derived class to disable preprocessing (which includes handling
accelerators) for specific keys. This is what wx itself uses to make key
combinations such as Ctrl-{C,V,X} etc to still work in wxTextCtrl even if
you use them as accelerators too.

But this is not really general and can only be done under MSW. I'm not
even sure if the other platforms have the same problem, but if they do, I
don't know how to solve it there.

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Reply all
Reply to author
Forward
0 new messages