How to disable RichTextCtrl's keyboard shortcut “CTRL + C”?

I’ve been trying to figure out how to make a “RichTextCtrl” do nothing when someone presses CTRL+C.

I import it with

import wx.richtext as rt

And I know how to it with “wx.TextCtr”, but it doesn’t work with “rt.RichTextCtrl”.

        def OnKeyDown(self, event):
code = event.GetKeyCode()
# If Ctrl+C is pressed...
if event.ControlDown() and code == 67:
return
event.Skip()

Any ideas?

That does sound odd.

Perhaps you should provide a pair of small example programs in which the only difference

is the TextCtrl used. so others can verify what you are seeing.

···

On Dec 6, 2017, at 2:53 PM, Rel Guzman r.guzmanap@gmail.com wrote:

I’ve been trying to figure out how to make a “RichTextCtrl” do nothing when someone presses CTRL+C.

I import it with

import wx.richtext as rt

And I know how to it with “wx.TextCtr”, but it doesn’t work with “rt.RichTextCtrl”.

        def OnKeyDown(self, event):
code = event.GetKeyCode()
# If Ctrl+C is pressed...
if event.ControlDown() and code == 67:
return
event.Skip()

Any ideas?

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.

Without digging into code, I seem to recall that the ctrl+C is intercepted at a higher level by the accelerator table, so grabbing it in your local key handler won’t do anything. Try adding a Copy method on your derived text control class and see if it gets there:

···
def Copy(self):
    print("Copy called.")
    super().Copy()  # Comment this out to disable actually copying anything.

On Wednesday, December 6, 2017 at 12:26:54 PM UTC-8, Rel Guzman wrote:

I’ve been trying to figure out how to make a “RichTextCtrl” do nothing when someone presses CTRL+C.

I import it with

import wx.richtext as rt

And I know how to it with “wx.TextCtr”, but it doesn’t work with “rt.RichTextCtrl”.

        def OnKeyDown(self, event):
code = event.GetKeyCode()
# If Ctrl+C is pressed...
if event.ControlDown() and code == 67:
return
event.Skip()

Any ideas?