From 98849bde9695a51556e0c4fe73c20eaac547db0d Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 1 Aug 2018 10:56:10 +0100 Subject: [PATCH] Generalize OSX &Cancel fix to work for other languages. Fixes: lp:1784350 * https://bugs.launchpad.net/kicad/+bug/1784350 --- common/dialog_shim.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/common/dialog_shim.cpp b/common/dialog_shim.cpp index 0f73cb8470..f1a9e08d73 100644 --- a/common/dialog_shim.cpp +++ b/common/dialog_shim.cpp @@ -262,13 +262,18 @@ static void fixOSXCancelButtonIssue( wxWindow *aWindow ) // 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( "&C" ), wxT( "C" ) ); - buttonLabel.Replace( wxT( "&c" ), wxT( "c" ) ); + buttonLabel.Replace( wxT( "&&" ), placeholder ); + buttonLabel.Replace( wxT( "&" ), wxEmptyString ); + buttonLabel.Replace( placeholder, wxT( "&" ) ); button->SetLabel( buttonLabel ); } }