Search code examples
macoswxpythonwxwidgetswxtextctrl

How to stop wxPython dialogs closing with Cmd+C


I'm working on a multi-platform app where users might open a modal dialog to enter text. However, on macos, instead of copying text, Command+C closes the modal.

This only happens with .ShowModal(), not .Show(). Doesn't seem to matter what has focus, or what type of wx.Dialog.

I assume this is a holdover from Linux systems, since Ctrl+C doesn't do the same thing (although it does add unicode ETX in a stc.StyledTextCtrl...)

How can I block this and allow a normal text copy action?

I'm using wxPython 4.0.1.


Solution

  • It turns out this is a very old bug that is yet to be fixed.

    wxPython: https://github.com/wxWidgets/Phoenix/issues/1134

    wxWidgets: http://trac.wxwidgets.org/ticket/15678

    The workaround is to avoid using wxStdDialogButtonSizer, and/or to no use wx.ID_CANCEL as a button ID.