Treat canvas item as current when tree view contains no selection.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/12702
This commit is contained in:
Jeff Young 2023-06-04 20:51:28 +01:00
parent 039f23eba8
commit 1528f4700c
8 changed files with 32 additions and 2 deletions

View File

@ -417,6 +417,12 @@ wxDataViewItem LIB_TREE_MODEL_ADAPTER::FindItem( const LIB_ID& aLibId )
}
wxDataViewItem LIB_TREE_MODEL_ADAPTER::GetCurrentDataViewItem()
{
return FindItem( m_preselect_lib_id );
}
unsigned int LIB_TREE_MODEL_ADAPTER::GetChildren( const wxDataViewItem& aItem,
wxDataViewItemArray& aChildren ) const
{

View File

@ -529,7 +529,11 @@ void LIB_TREE::onDebounceTimer( wxTimerEvent& aEvent )
void LIB_TREE::onQueryCharHook( wxKeyEvent& aKeyStroke )
{
const wxDataViewItem sel = m_tree_ctrl->GetSelection();
wxDataViewItem sel = m_tree_ctrl->GetSelection();
if( !sel.IsOk() )
sel = m_adapter->GetCurrentDataViewItem();
LIB_TREE_NODE::TYPE type = sel.IsOk() ? m_adapter->GetTypeFor( sel ) : LIB_TREE_NODE::INVALID;
switch( aKeyStroke.GetKeyCode() )

View File

@ -208,6 +208,15 @@ SYMBOL_TREE_SYNCHRONIZING_ADAPTER::deleteLibrary( LIB_TREE_NODE::PTR_VECTOR::ite
}
wxDataViewItem SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetCurrentDataViewItem()
{
if( m_frame->GetCurSymbol() )
return FindItem( m_frame->GetCurSymbol()->GetLibId() );
return wxDataViewItem();
}
void SYMBOL_TREE_SYNCHRONIZING_ADAPTER::GetValue( wxVariant& aVariant, wxDataViewItem const& aItem,
unsigned int aCol ) const
{

View File

@ -48,6 +48,8 @@ public:
TOOL_INTERACTIVE* GetContextMenuTool() override;
wxDataViewItem GetCurrentDataViewItem() override;
protected:
void updateLibrary( LIB_TREE_NODE_LIB& aLibNode );

View File

@ -283,6 +283,8 @@ public:
*/
wxDataViewItem FindItem( const LIB_ID& aLibId );
virtual wxDataViewItem GetCurrentDataViewItem();
/**
* Populate a list of all the children of an item
*

View File

@ -230,7 +230,6 @@ protected:
wxTimer* m_debounceTimer;
bool m_inTimerEvent;
LIB_ID m_last_libid;
wxString m_recentSearchesKey;
bool m_skipNextRightClick;

View File

@ -169,6 +169,12 @@ FP_TREE_SYNCHRONIZING_ADAPTER::deleteLibrary( LIB_TREE_NODE::PTR_VECTOR::iterato
}
wxDataViewItem FP_TREE_SYNCHRONIZING_ADAPTER::GetCurrentDataViewItem()
{
return FindItem( m_frame->GetLoadedFPID() );
}
void FP_TREE_SYNCHRONIZING_ADAPTER::GetValue( wxVariant& aVariant, wxDataViewItem const& aItem,
unsigned int aCol ) const
{

View File

@ -44,6 +44,8 @@ public:
TOOL_INTERACTIVE* GetContextMenuTool() override;
wxDataViewItem GetCurrentDataViewItem() override;
protected:
FP_TREE_SYNCHRONIZING_ADAPTER( FOOTPRINT_EDIT_FRAME* aFrame, FP_LIB_TABLE* aLibs );