Only the first wxRichTextCtrl receives keyboard shortcut edit commands

Hello,

Happy New Year to all!

I’m running wxPython (version 3.0.0.0) on Mac OS X and am running into a weird issue with the RichTextCtrl: when there’s more than one RTC sharing the same parent container, only the first RTC receives the Cmd-A (select all), Cmd-C (copy), Cmd-V (paste) keyboard commands. I’ve attached minimal sample code that replicates the problem.

I’ve found even if I have a mix of just one wxRichTextCtrl and a handful of wxTextCtrls on the form I’ll get the same behavior if one of the non-RTC controls has focus as well. I’ve tried this on OS X Mountain Lion and Mavericks with the same result.

Does anybody know what might be causing this behavior? Am I using the RTC widget properly? Is it possible the issue might originate from the upstream wxWidgets project and I should ask there? If somebody’s familiar with how the events mechanism works and can offer a workaround, I’d appreciate the help.

Thanks,

OC

rtctest.py (1.13 KB)

The sample seems to be working fine here (Win7).

Good luck.

Cheers,

Scott.

···

On Fri, Jan 2, 2015 at 12:44 PM, OC ocamler@gmail.com wrote:

Hello,

Happy New Year to all!

I’m running wxPython (version 3.0.0.0) on Mac OS X and am running into a weird issue with the RichTextCtrl: when there’s more than one RTC sharing the same parent container, only the first RTC receives the Cmd-A (select all), Cmd-C (copy), Cmd-V (paste) keyboard commands. I’ve attached minimal sample code that replicates the problem.

I’ve found even if I have a mix of just one wxRichTextCtrl and a handful of wxTextCtrls on the form I’ll get the same behavior if one of the non-RTC controls has focus as well. I’ve tried this on OS X Mountain Lion and Mavericks with the same result.

Does anybody know what might be causing this behavior? Am I using the RTC widget properly? Is it possible the issue might originate from the upstream wxWidgets project and I should ask there? If somebody’s familiar with how the events mechanism works and can offer a workaround, I’d appreciate the help.

Thanks,

OC

You received this message because you are subscribed to the Google Groups “wxPython-users” group.

To unsubscribe from this group and stop receiving emails from it, send an email to wxpython-users+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Happy New Year :slight_smile:

I’ve had the same issue and raised an issue here:

http://trac.wxwidgets.org/ticket/16729

It seams the problem possibly involves some bug in RTC with handling keyboard events in OSX code – not really something I know how to debug, so I didn’t try hoping someone else would find it easier to do. No response yet though…

···

Toni

On Friday, January 2, 2015 6:44:02 PM UTC+1, OC wrote:

Hello,

Happy New Year to all!

I’m running wxPython (version 3.0.0.0) on Mac OS X and am running into a weird issue with the RichTextCtrl: when there’s more than one RTC sharing the same parent container, only the first RTC receives the Cmd-A (select all), Cmd-C (copy), Cmd-V (paste) keyboard commands. I’ve attached minimal sample code that replicates the problem.

I’ve found even if I have a mix of just one wxRichTextCtrl and a handful of wxTextCtrls on the form I’ll get the same behavior if one of the non-RTC controls has focus as well. I’ve tried this on OS X Mountain Lion and Mavericks with the same result.

Does anybody know what might be causing this behavior? Am I using the RTC widget properly? Is it possible the issue might originate from the upstream wxWidgets project and I should ask there? If somebody’s familiar with how the events mechanism works and can offer a workaround, I’d appreciate the help.

Thanks,

OC

Hi Steve and Toni,

I appreciate your taking the time to weigh in on this. Looks like the problem with RichTextCtrl stealing menu event commands is Mac-specific. If I have time to circle back to setting up wxWidgets and seeing if I can reproduce the same problem in a C++ version, I’ll try to add it to your Trac ticket, Toni.

As a short-term workaround I’ve decided to intercept the menu event commands (cut, copy, paste, select all) on Mac with my own accelerator table and handle them in my own code. Mike Driscoll’s helpful blog entries helped me sort it all out:

Attached is the final result which I used to solve the problem on Mac, albeit crudely. It doesn’t help if you need to use a wxComboBox on the form too, since there appears to be no way to retrieve just the highlighted/swiped text from a combo box. :frowning: Fortunately my app doesn’t have an RTC and ComboBox on the same form, so I lucked out there.

Regards,

OC

rtctest5.py (2.49 KB)

···

On Sunday, January 4, 2015 2:02:26 AM UTC-5, Toni Ruža wrote:

Happy New Year :slight_smile:

I’ve had the same issue and raised an issue here:

http://trac.wxwidgets.org/ticket/16729

It seams the problem possibly involves some bug in RTC with handling keyboard events in OSX code – not really something I know how to debug, so I didn’t try hoping someone else would find it easier to do. No response yet though…

Toni

On Friday, January 2, 2015 6:44:02 PM UTC+1, OC wrote:

Hello,

Happy New Year to all!

I’m running wxPython (version 3.0.0.0) on Mac OS X and am running into a weird issue with the RichTextCtrl: when there’s more than one RTC sharing the same parent container, only the first RTC receives the Cmd-A (select all), Cmd-C (copy), Cmd-V (paste) keyboard commands. I’ve attached minimal sample code that replicates the problem.

I’ve found even if I have a mix of just one wxRichTextCtrl and a handful of wxTextCtrls on the form I’ll get the same behavior if one of the non-RTC controls has focus as well. I’ve tried this on OS X Mountain Lion and Mavericks with the same result.

Does anybody know what might be causing this behavior? Am I using the RTC widget properly? Is it possible the issue might originate from the upstream wxWidgets project and I should ask there? If somebody’s familiar with how the events mechanism works and can offer a workaround, I’d appreciate the help.

Thanks,

OC