LIB_TREE's SetFocus() override no longer getting called.

The KIPLATFORM stuff forces focus, but not through the SetFocus()
call.

Fixes https://gitlab.com/kicad/code/kicad/issues/6657
This commit is contained in:
Jeff Young 2020-12-08 17:44:44 +00:00
parent ac684ac7a3
commit b26a5972c5
4 changed files with 35 additions and 6 deletions

View File

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

View File

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

View File

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

View File

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