Footprint Editor: Focus search field when window is first opened

The search field on the Symbol Editor is focused when its window 
is first opened. Similar behavior has been implemented in the search
field of the Footprint Editor with this change.

Fixes: https://gitlab.com/kicad/code/kicad/-/issues/13100
This commit is contained in:
Tanay Gupta 2022-12-20 19:54:02 +00:00 committed by Seth Hillbrand
parent 8e4911bba2
commit b0cbab5c4b
5 changed files with 35 additions and 5 deletions

View File

@ -325,6 +325,15 @@ wxWindow* LIB_TREE::GetFocusTarget()
} }
void LIB_TREE::FocusSearchFieldIfExists()
{
if( m_query_ctrl )
{
m_query_ctrl->SetFocus();
}
}
void LIB_TREE::toggleExpand( const wxDataViewItem& aTreeId ) void LIB_TREE::toggleExpand( const wxDataViewItem& aTreeId )
{ {
if( !aTreeId.IsOk() ) if( !aTreeId.IsOk() )

View File

@ -139,6 +139,11 @@ public:
wxWindow* GetFocusTarget(); wxWindow* GetFocusTarget();
/**
* Focus the search widget if it exists
*/
void FocusSearchFieldIfExists();
protected: protected:
/** /**
* Expand or collapse a node, switching it to the opposite state. * Expand or collapse a node, switching it to the opposite state.

View File

@ -309,11 +309,13 @@ FOOTPRINT_EDIT_FRAME::FOOTPRINT_EDIT_FRAME( KIWAY* aKiway, wxWindow* aParent ) :
// Register a call to update the toolbar sizes. It can't be done immediately because // Register a call to update the toolbar sizes. It can't be done immediately because
// it seems to require some sizes calculated that aren't yet (at least on GTK). // it seems to require some sizes calculated that aren't yet (at least on GTK).
CallAfter( [&]() CallAfter(
{ [&]()
// Ensure the controls on the toolbars all are correctly sized {
UpdateToolbarControlSizes(); // Ensure the controls on the toolbars all are correctly sized
} ); UpdateToolbarControlSizes();
m_treePane->FocusSearchFieldIfExists();
} );
} }

View File

@ -50,6 +50,15 @@ FOOTPRINT_TREE_PANE::FOOTPRINT_TREE_PANE( FOOTPRINT_EDIT_FRAME* aParent )
} }
void FOOTPRINT_TREE_PANE::FocusSearchFieldIfExists()
{
if( m_tree )
{
m_tree->FocusSearchFieldIfExists();
}
}
FOOTPRINT_TREE_PANE::~FOOTPRINT_TREE_PANE() FOOTPRINT_TREE_PANE::~FOOTPRINT_TREE_PANE()
{ {
m_tree->Destroy(); m_tree->Destroy();

View File

@ -47,6 +47,11 @@ public:
return m_tree; return m_tree;
} }
/**
* Focus the search widget if it exists
*/
void FocusSearchFieldIfExists();
protected: protected:
void onComponentSelected( wxCommandEvent& aEvent ); void onComponentSelected( wxCommandEvent& aEvent );
void onUpdateUI( wxUpdateUIEvent& aEvent ); void onUpdateUI( wxUpdateUIEvent& aEvent );