RichTextCtrl -- Catching copy, cut, paste accelerators for use in overridden methods

Visto 41 veces
Saltar al primer mensaje no leído

Todd L

no leída,
7 ago 2018, 0:22:397/8/18
a wxPython-users
Hi all,

I'm having an issue with RichTextCtrl (RTC) and the Ctrl+C, Ctrl+V, and Ctrl+X accelerators.  Part of the program needs to know when the user copies, pastes, and cuts into the RTC.  The user can do this from a menu, or with the keyboard accelerators.  The most straightforward solution to do this is to override the RTC's functions, within which we do all the custom stuff first, then call e.g. super().Cut().  This works fine when calling from a menu, but the accelerators bypass the override functions for some reason, which leads me to wonder if the RTC's Copy(), Paste(), and Cut() methods are even called when the accelerators are used.  Any ideas on how to catch these accelerators?  I believe this was explored a bit in another post (link below) but never fully resolved.


Sample code provided to demonstrate the issue, try copy/cut/paste from the menu then with accelerators.  Thanks!

sample.py

Robin Dunn

no leída,
7 ago 2018, 14:55:467/8/18
a wxPython-users
Those methods are not wrapped with the virtual flag, which means that calls to them from internal C++ code will not be routed through Python overrides. Virtualness is turned off in most cases because it saves a bunch overhead in the wrappers and most of the time it is not needed from Python, but I agree that in this case it makes sense to allow the clipboard-related methods to be overridden. I've added an issue for it.


--
Robin

Todd L

no leída,
7 ago 2018, 21:08:317/8/18
a wxPython-users
Great, thanks much!
Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos