Make sure CvPcb gets its Cancel button fixed up.

It's no longer a DIALOG_SHIM so it can't depend on its fixup.

Fixes https://gitlab.com/kicad/code/kicad/issues/4611
This commit is contained in:
Jeff Young 2020-06-04 22:26:15 +01:00
parent b274b9f972
commit 0ddf53397f
7 changed files with 46 additions and 30 deletions

View File

@ -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<wxButton*>( 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() );

View File

@ -48,6 +48,7 @@
#include <tools/cvpcb_actions.h>
#include <tools/cvpcb_association_tool.h>
#include <tools/cvpcb_control.h>
#include <libs/kiplatform/include/kiplatform/ui.h>
#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) );

View File

@ -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:
/**

View File

@ -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
}

View File

@ -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 );
}
}

View File

@ -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
}

View File

@ -24,7 +24,7 @@
#include <wx/nonownedwnd.h>
#include <wx/toplevel.h>
#include <wx/window.h>
#include <wx/button.h>
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<wxButton*>( 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 );
}
}