From 80e7a83fb08c6c04336389a149062db7a13c4129 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 (cherry picked from commit 98849bde9695a51556e0c4fe73c20eaac547db0d) --- 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 f3b58f0164..5c99067b99 100644 --- a/common/dialog_shim.cpp +++ b/common/dialog_shim.cpp @@ -255,13 +255,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 ); } }