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

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Todd L
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!

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.

sample.py (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

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

Robin Dunn
On Monday, August 6, 2018 at 9:22:39 PM UTC-7, Todd L wrote:
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!

Similar post: <a href="https://groups.google.com/forum/#!searchin/wxpython-users/richtextctrl%7Csort:date/wxpython-users/RRwj7TaiqHc/VouLsY_FBwAJ" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/forum/#!searchin/wxpython-users/richtextctrl%7Csort:date/wxpython-users/RRwj7TaiqHc/VouLsY_FBwAJ&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/forum/#!searchin/wxpython-users/richtextctrl%7Csort:date/wxpython-users/RRwj7TaiqHc/VouLsY_FBwAJ&#39;;return true;">https://groups.google.com/forum/#!searchin/wxpython-users/richtextctrl%7Csort:date/wxpython-users/RRwj7TaiqHc/VouLsY_FBwAJ


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.

https://github.com/wxWidgets/Phoenix/issues/954

--
Robin

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

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

Todd L
In reply to this post by Todd L
Great, thanks much!

On Tuesday, August 7, 2018 at 12:22:39 AM UTC-4, Todd L wrote:
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!

Similar post: <a href="https://groups.google.com/forum/#!searchin/wxpython-users/richtextctrl%7Csort:date/wxpython-users/RRwj7TaiqHc/VouLsY_FBwAJ" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/forum/#!searchin/wxpython-users/richtextctrl%7Csort:date/wxpython-users/RRwj7TaiqHc/VouLsY_FBwAJ&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/forum/#!searchin/wxpython-users/richtextctrl%7Csort:date/wxpython-users/RRwj7TaiqHc/VouLsY_FBwAJ&#39;;return true;">https://groups.google.com/forum/#!searchin/wxpython-users/richtextctrl%7Csort:date/wxpython-users/RRwj7TaiqHc/VouLsY_FBwAJ

--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.