Pass focus back to canvas from appearance panel

Fixes https://gitlab.com/kicad/code/kicad/-/issues/5225
This commit is contained in:
Jon Evans 2020-08-17 21:57:49 -04:00
parent 3c66f932bf
commit ab7c96f672
2 changed files with 24 additions and 0 deletions

View File

@ -91,6 +91,7 @@ APPEARANCE_CONTROLS::APPEARANCE_CONTROLS( PCB_BASE_FRAME* aParent, wxWindow* aFo
bool aFpEditorMode ) : bool aFpEditorMode ) :
APPEARANCE_CONTROLS_BASE( aParent ), APPEARANCE_CONTROLS_BASE( aParent ),
m_frame( aParent ), m_frame( aParent ),
m_focusOwner( aFocusOwner ),
m_board( nullptr ), m_board( nullptr ),
m_currentPreset( nullptr ), m_currentPreset( nullptr ),
m_layerContextMenu( nullptr ), m_layerContextMenu( nullptr ),
@ -126,6 +127,7 @@ APPEARANCE_CONTROLS::APPEARANCE_CONTROLS( PCB_BASE_FRAME* aParent, wxWindow* aFo
m_frame->SetDisplayOptions( opts ); m_frame->SetDisplayOptions( opts );
m_frame->GetCanvas()->SetHighContrastLayer( m_frame->GetActiveLayer() ); m_frame->GetCanvas()->SetHighContrastLayer( m_frame->GetActiveLayer() );
m_frame->GetCanvas()->Refresh(); m_frame->GetCanvas()->Refresh();
passOnFocus();
}; };
m_rbHighContrastNormal->Bind( wxEVT_RADIOBUTTON, m_rbHighContrastNormal->Bind( wxEVT_RADIOBUTTON,
@ -962,7 +964,10 @@ void APPEARANCE_CONTROLS::onObjectVisibilityChanged( GAL_LAYER_ID aLayer, bool i
} }
if( isFinal ) if( isFinal )
{
m_frame->GetCanvas()->Refresh(); m_frame->GetCanvas()->Refresh();
passOnFocus();
}
} }
@ -1215,6 +1220,7 @@ void APPEARANCE_CONTROLS::rebuildNets()
m_frame->GetCanvas()->RedrawRatsnest(); m_frame->GetCanvas()->RedrawRatsnest();
m_frame->GetCanvas()->Refresh(); m_frame->GetCanvas()->Refresh();
passOnFocus();
} ); } );
bool visible = hiddenNets.count( netCode ) == 0; bool visible = hiddenNets.count( netCode ) == 0;
@ -1249,6 +1255,7 @@ void APPEARANCE_CONTROLS::rebuildNets()
PCB_ACTIONS::hideNet; PCB_ACTIONS::hideNet;
m_frame->GetToolManager()->RunAction( action, true, net ); m_frame->GetToolManager()->RunAction( action, true, net );
passOnFocus();
} ); } );
const wxString& netName = aNet->GetShortNetname(); const wxString& netName = aNet->GetShortNetname();
@ -1572,6 +1579,7 @@ void APPEARANCE_CONTROLS::onLayerPresetChanged( wxCommandEvent& aEvent )
m_currentPreset = preset; m_currentPreset = preset;
doApplyLayerPreset( *preset ); doApplyLayerPreset( *preset );
passOnFocus();
} }
@ -1616,6 +1624,8 @@ void APPEARANCE_CONTROLS::OnColorSwatchChanged( wxCommandEvent& aEvent )
if( layer == LAYER_PCB_BACKGROUND ) if( layer == LAYER_PCB_BACKGROUND )
m_frame->SetDrawBgColor( newColor ); m_frame->SetDrawBgColor( newColor );
passOnFocus();
} }
@ -1633,6 +1643,7 @@ void APPEARANCE_CONTROLS::onObjectOpacitySlider( int aLayer, float aOpacity )
} }
m_frame->SetDisplayOptions( options ); m_frame->SetDisplayOptions( options );
passOnFocus();
} }
@ -1711,6 +1722,7 @@ void APPEARANCE_CONTROLS::onNetContextMenu( wxCommandEvent& aEvent )
m_frame->GetCanvas()->Refresh(); m_frame->GetCanvas()->Refresh();
m_contextMenuNetCode = 0; m_contextMenuNetCode = 0;
passOnFocus();
} }
@ -1719,6 +1731,7 @@ void APPEARANCE_CONTROLS::onNetclassVisibilityChanged( wxCommandEvent& aEvent )
wxString className = netclassNameFromEvent( aEvent ); wxString className = netclassNameFromEvent( aEvent );
bool show = aEvent.GetInt(); bool show = aEvent.GetInt();
showNetclass( className, show ); showNetclass( className, show );
passOnFocus();
} }
@ -1816,6 +1829,7 @@ void APPEARANCE_CONTROLS::onNetColorModeChanged( wxCommandEvent& aEvent )
m_frame->SetDisplayOptions( options ); m_frame->SetDisplayOptions( options );
m_frame->GetCanvas()->GetView()->UpdateAllLayersColor(); m_frame->GetCanvas()->GetView()->UpdateAllLayersColor();
passOnFocus();
} }
@ -1943,3 +1957,9 @@ void APPEARANCE_CONTROLS::onNetclassContextMenu( wxCommandEvent& aEvent )
m_contextMenuNetclass.clear(); m_contextMenuNetclass.clear();
} }
void APPEARANCE_CONTROLS::passOnFocus()
{
m_focusOwner->SetFocus();
}

View File

@ -154,6 +154,8 @@ protected:
private: private:
PCB_BASE_FRAME* m_frame; PCB_BASE_FRAME* m_frame;
wxWindow* m_focusOwner;
static const APPEARANCE_SETTING s_objectSettings[]; static const APPEARANCE_SETTING s_objectSettings[];
ROW_ICON_PROVIDER* m_iconProvider; ROW_ICON_PROVIDER* m_iconProvider;
@ -278,6 +280,8 @@ private:
void onNetclassContextMenu( wxCommandEvent& aEvent ); void onNetclassContextMenu( wxCommandEvent& aEvent );
void handleBoardItemsChanged(); void handleBoardItemsChanged();
void passOnFocus();
}; };
#endif #endif