diff --git a/common/dialog_shim.cpp b/common/dialog_shim.cpp index 12e69e18cf..eae7a9d9aa 100644 --- a/common/dialog_shim.cpp +++ b/common/dialog_shim.cpp @@ -297,38 +297,11 @@ static void selectAllInTextCtrls( wxWindowList& children ) } -#ifdef __WXMAC__ -static void fixOSXCancelButtonIssue( wxWindow *aWindow ) -{ - // A ugly hack to fix an issue on OSX: cmd+c closes the dialog instead of - // copying the text if a button with wxID_CANCEL is used in a - // wxStdDialogButtonSizer created by wxFormBuilder: the label is &Cancel, and - // this accelerator key has priority over the standard copy accelerator. - // Note: problem also exists in other languages; for instance cmd+a closes - // dialogs in German because the button is &Abbrechen. - wxButton* button = dynamic_cast( wxWindow::FindWindowById( wxID_CANCEL, aWindow ) ); - - if( button ) - { - static const wxString placeholder = wxT( "{amp}" ); - - wxString buttonLabel = button->GetLabel(); - buttonLabel.Replace( wxT( "&&" ), placeholder ); - buttonLabel.Replace( wxT( "&" ), wxEmptyString ); - buttonLabel.Replace( placeholder, wxT( "&" ) ); - button->SetLabel( buttonLabel ); - } -} -#endif - - void DIALOG_SHIM::OnPaint( wxPaintEvent &event ) { if( m_firstPaintEvent ) { -#ifdef __WXMAC__ - fixOSXCancelButtonIssue( this ); -#endif + KIPLATFORM::UI::FixupCancelButtonCmdKeyCollision( this ); selectAllInTextCtrls( GetChildren() ); diff --git a/cvpcb/cvpcb_mainframe.cpp b/cvpcb/cvpcb_mainframe.cpp index f90f869887..da143f54d6 100644 --- a/cvpcb/cvpcb_mainframe.cpp +++ b/cvpcb/cvpcb_mainframe.cpp @@ -48,6 +48,7 @@ #include #include #include +#include #define CVPCB_MAINFRAME_NAME wxT( "CvpcbFrame" ) @@ -149,6 +150,7 @@ CVPCB_MAINFRAME::CVPCB_MAINFRAME( KIWAY* aKiway, wxWindow* aParent ) : bottomPanel->Fit(); sdbSizerOK->SetDefault(); + KIPLATFORM::UI::FixupCancelButtonCmdKeyCollision( this ); m_auimgr.AddPane( bottomPanel, EDA_PANE().HToolbar().Name( "Buttons" ).Bottom().Layer(6) ); diff --git a/include/dialog_shim.h b/include/dialog_shim.h index 6bc13af044..2ef79229f8 100644 --- a/include/dialog_shim.h +++ b/include/dialog_shim.h @@ -70,7 +70,6 @@ class WX_EVENT_LOOP; #define SHOWQUASIMODAL ShowQuasiModal #define ENDQUASIMODAL EndQuasiModal - /** * Dialog helper object to sit in the inheritance tree between wxDialog and any class written * by wxFormBuilder. @@ -146,6 +145,8 @@ public: e.ShiftDown() && !e.MetaDown(); } + static void FixOSXCancelButtonIssue( wxWindow *aWindow ); + protected: /** diff --git a/libs/kiplatform/gtk/ui.cpp b/libs/kiplatform/gtk/ui.cpp index 06d2a082d5..b20fe98631 100644 --- a/libs/kiplatform/gtk/ui.cpp +++ b/libs/kiplatform/gtk/ui.cpp @@ -33,3 +33,9 @@ void KIPLATFORM::UI::ReparentQuasiModal( wxNonOwnedWindow* aWindow ) { // Not needed on this platform } + + +void KIPLATFORM::UI::FixupCancelButtonCmdCopyCollision( wxWindow *aWindow ) +{ + // Not needed on this platform +} diff --git a/libs/kiplatform/include/kiplatform/ui.h b/libs/kiplatform/include/kiplatform/ui.h index 5f15420749..cfb367c697 100644 --- a/libs/kiplatform/include/kiplatform/ui.h +++ b/libs/kiplatform/include/kiplatform/ui.h @@ -50,6 +50,16 @@ namespace KIPLATFORM * @param aWindow is the window to reparent */ void ReparentQuasiModal( wxNonOwnedWindow* aWindow ); + + /* + * An ugly hack to fix an issue on OSX: cmd+c closes the dialog instead of copying the + * text if a button with wxID_CANCEL is used in a wxStdDialogButtonSizer created by + * wxFormBuilder: the label is &Cancel, and this accelerator key has priority over the + * standard copy accelerator. + * Note: problem also exists in other languages; for instance cmd+a closes dialogs in + * German because the button is &Abbrechen. + */ + void FixupCancelButtonCmdKeyCollision( wxWindow* aWindow ); } } diff --git a/libs/kiplatform/msw/ui.cpp b/libs/kiplatform/msw/ui.cpp index 06d2a082d5..b20fe98631 100644 --- a/libs/kiplatform/msw/ui.cpp +++ b/libs/kiplatform/msw/ui.cpp @@ -33,3 +33,9 @@ void KIPLATFORM::UI::ReparentQuasiModal( wxNonOwnedWindow* aWindow ) { // Not needed on this platform } + + +void KIPLATFORM::UI::FixupCancelButtonCmdCopyCollision( wxWindow *aWindow ) +{ + // Not needed on this platform +} diff --git a/libs/kiplatform/osx/ui.mm b/libs/kiplatform/osx/ui.mm index d3a7ddc960..840733a987 100644 --- a/libs/kiplatform/osx/ui.mm +++ b/libs/kiplatform/osx/ui.mm @@ -24,7 +24,7 @@ #include #include -#include +#include void KIPLATFORM::UI::ForceFocus( wxWindow* aWindow ) { @@ -45,3 +45,21 @@ void KIPLATFORM::UI::ReparentQuasiModal( wxNonOwnedWindow* aWindow ) [parentWindow addChildWindow:theWindow ordered:NSWindowAbove]; } + + +void KIPLATFORM::UI::FixupCancelButtonCmdKeyCollision( wxWindow *aWindow ) +{ + wxButton* button = dynamic_cast( wxWindow::FindWindowById( wxID_CANCEL, aWindow ) ); + + if( button ) + { + static const wxString placeholder = wxT( "{amp}" ); + + wxString buttonLabel = button->GetLabel(); + buttonLabel.Replace( wxT( "&&" ), placeholder ); + buttonLabel.Replace( wxT( "&" ), wxEmptyString ); + buttonLabel.Replace( placeholder, wxT( "&" ) ); + button->SetLabel( buttonLabel ); + } +} +