Fix buttons in appearance panel in MSW

Ensure we pass the focus back to the canvas when
closing dialogs that might have been launched from the
appearance panel

Fixes https://gitlab.com/kicad/code/kicad/-/issues/5326
This commit is contained in:
Jon Evans 2020-08-23 15:42:20 -04:00
parent a03fb7a9a8
commit 8e03d278f0
3 changed files with 17 additions and 0 deletions

View File

@ -185,6 +185,8 @@ DIALOG_SELECT_NET_FROM_LIST::~DIALOG_SELECT_NET_FROM_LIST()
if( m_brd != nullptr )
m_brd->RemoveListener( this );
m_frame->GetCanvas()->SetFocus();
}

View File

@ -918,6 +918,8 @@ void PCB_EDIT_FRAME::ShowBoardSetupDialog( const wxString& aInitialPage, const w
OnModify();
}
GetCanvas()->SetFocus();
}

View File

@ -400,6 +400,7 @@ APPEARANCE_CONTROLS::APPEARANCE_CONTROLS( PCB_BASE_FRAME* aParent, wxWindow* aFo
[&]( wxCommandEvent& aEvent )
{
m_frame->GetToolManager()->RunAction( PCB_ACTIONS::listNets, true );
passOnFocus();
} );
m_btnConfigureNetClasses->Bind( wxEVT_BUTTON,
@ -408,6 +409,8 @@ APPEARANCE_CONTROLS::APPEARANCE_CONTROLS( PCB_BASE_FRAME* aParent, wxWindow* aFo
// This panel should only be visible in the PCB_EDIT_FRAME anyway
if( PCB_EDIT_FRAME* editframe = dynamic_cast<PCB_EDIT_FRAME*>( m_frame ) )
editframe->ShowBoardSetupDialog( _( "Net Classes" ) );
passOnFocus();
} );
m_cbFlipBoard->SetValue( m_frame->GetCanvas()->GetView()->IsMirroredX() );
@ -537,6 +540,16 @@ void APPEARANCE_CONTROLS::idleFocusHandler( wxIdleEvent& aEvent )
void APPEARANCE_CONTROLS::OnSetFocus( wxFocusEvent& aEvent )
{
#ifdef __WXMSW__
// In wxMSW, buttons won't process events unless they have focus, so we'll let it take the
// focus and give it back to the parent in the button event handler.
if( wxBitmapButton* btn = dynamic_cast<wxBitmapButton*>( aEvent.GetEventObject() ) )
{
wxCommandEvent evt( wxEVT_BUTTON );
wxPostEvent( btn, evt );
}
#endif
passOnFocus();
aEvent.Skip();
}