diff --git a/common/widgets/lib_tree.cpp b/common/widgets/lib_tree.cpp index 1efd2e176d..c67ab600ea 100644 --- a/common/widgets/lib_tree.cpp +++ b/common/widgets/lib_tree.cpp @@ -110,6 +110,12 @@ LIB_TREE::LIB_TREE( wxWindow* aParent, LIB_TABLE* aLibTable, m_tree_ctrl->Bind( wxEVT_DATAVIEW_SELECTION_CHANGED, &LIB_TREE::onTreeSelect, this ); m_tree_ctrl->Bind( wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, &LIB_TREE::onContextMenu, this ); + if( m_query_ctrl ) + { + m_query_ctrl->Bind( wxEVT_SET_FOCUS, &LIB_TREE::onFocus, this ); + m_query_ctrl->Bind( wxEVT_KILL_FOCUS, &LIB_TREE::onKillFocus, this ); + } + Bind( COMPONENT_PRESELECTED, &LIB_TREE::onPreselect, this ); // If wxTextCtrl::SetHint() is called before binding wxEVT_TEXT, the event @@ -148,6 +154,18 @@ LIB_TREE::~LIB_TREE() } +void LIB_TREE::onFocus( wxFocusEvent& aEvent ) +{ + m_label = "OnFOCUS"; +} + + +void LIB_TREE::onKillFocus( wxFocusEvent& aEvent ) +{ + m_label = "OnKILLFOCUS"; +} + + LIB_ID LIB_TREE::GetSelectedLibId( int* aUnit ) const { auto sel = m_tree_ctrl->GetSelection(); @@ -224,12 +242,12 @@ void LIB_TREE::RefreshLibTree() } -void LIB_TREE::SetFocus() +wxWindow* LIB_TREE::GetFocusTarget() { if( m_query_ctrl ) - m_query_ctrl->SetFocus(); + return m_query_ctrl; else - m_tree_ctrl->SetFocus(); + return m_tree_ctrl; } diff --git a/common/widgets/lib_tree.h b/common/widgets/lib_tree.h index f29f0d1f81..cbbd6a9d34 100644 --- a/common/widgets/lib_tree.h +++ b/common/widgets/lib_tree.h @@ -104,7 +104,7 @@ public: */ void RefreshLibTree(); - void SetFocus() override; + wxWindow* GetFocusTarget(); protected: /** @@ -155,6 +155,9 @@ protected: */ void setState( const STATE& aState ); + void onFocus( wxFocusEvent& aEvent ); + void onKillFocus( wxFocusEvent& aEvent ); + void onQueryText( wxCommandEvent& aEvent ); void onQueryEnter( wxCommandEvent& aEvent ); void onQueryCharHook( wxKeyEvent& aEvent ); diff --git a/eeschema/dialogs/dialog_choose_component.cpp b/eeschema/dialogs/dialog_choose_component.cpp index 4cbb904af8..5e069d3705 100644 --- a/eeschema/dialogs/dialog_choose_component.cpp +++ b/eeschema/dialogs/dialog_choose_component.cpp @@ -158,15 +158,17 @@ DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const horizPixelsFromDU( 220 ) ); if( m_vsplitter ) + { m_vsplitter->SetSashPosition( panelCfg.sash_pos_v > 0 ? panelCfg.sash_pos_v : vertPixelsFromDU( 230 ) ); + } wxSize dlgSize( panelCfg.width > 0 ? panelCfg.width : horizPixelsFromDU( 390 ), panelCfg.height > 0 ? panelCfg.height : vertPixelsFromDU( 300 ) ); SetSize( dlgSize ); } - SetInitialFocus( m_tree ); + SetInitialFocus( m_tree->GetFocusTarget() ); okButton->SetDefault(); Bind( wxEVT_INIT_DIALOG, &DIALOG_CHOOSE_COMPONENT::OnInitDialog, this ); @@ -175,17 +177,23 @@ DIALOG_CHOOSE_COMPONENT::DIALOG_CHOOSE_COMPONENT( SCH_BASE_FRAME* aParent, const Bind( COMPONENT_SELECTED, &DIALOG_CHOOSE_COMPONENT::OnComponentSelected, this ); if( m_browser_button ) + { m_browser_button->Bind( wxEVT_COMMAND_BUTTON_CLICKED, &DIALOG_CHOOSE_COMPONENT::OnUseBrowser, this ); + } if( m_fp_sel_ctrl ) + { m_fp_sel_ctrl->Bind( EVT_FOOTPRINT_SELECTED, &DIALOG_CHOOSE_COMPONENT::OnFootprintSelected, this ); + } if( m_details ) + { m_details->Connect( wxEVT_CHAR_HOOK, wxKeyEventHandler( DIALOG_CHOOSE_COMPONENT::OnCharHook ), NULL, this ); + } } diff --git a/pcbnew/dialogs/dialog_choose_footprint.cpp b/pcbnew/dialogs/dialog_choose_footprint.cpp index 92ea356646..f0bec5752d 100644 --- a/pcbnew/dialogs/dialog_choose_footprint.cpp +++ b/pcbnew/dialogs/dialog_choose_footprint.cpp @@ -134,7 +134,7 @@ DIALOG_CHOOSE_FOOTPRINT::DIALOG_CHOOSE_FOOTPRINT( PCB_BASE_FRAME* aParent, horizPixelsFromDU( 340 ) : cfg->m_FootprintChooser.height; SetSize( wxSize( w, h ) ); - SetInitialFocus( m_tree ); + SetInitialFocus( m_tree->GetFocusTarget() ); okButton->SetDefault(); }