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

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

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

Rel Guzman

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

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

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

--
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: How to disable RichTextCtrl's keyboard shortcut “CTRL + C”?

efahl
In reply to this post by Rel Guzman
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?

--
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.