Fix for LIB_TREE hotkeys over canvas and possible fix for over LIB_TREE itself.

Fixes https://gitlab.com/kicad/code/kicad/issues/11034
This commit is contained in:
Jeff Young 2022-10-02 22:20:25 +01:00
parent e055302a3c
commit e335c1c612
3 changed files with 23 additions and 1 deletions

View File

@ -30,6 +30,7 @@
#include <dialogs/eda_reorderable_list_dialog.h>
#include <tool/tool_interactive.h>
#include <tool/tool_manager.h>
#include <tool/action_manager.h>
#include <tool/actions.h>
#include <wx/srchctrl.h>
#include <wx/settings.h>
@ -138,6 +139,9 @@ LIB_TREE::LIB_TREE( wxWindow* aParent, const wxString& aRecentSearchesKey, LIB_T
m_tree_ctrl->Bind( wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK, &LIB_TREE::onHeaderContextMenu,
this );
// Process hotkeys when the tree control has focus:
m_tree_ctrl->Bind( wxEVT_CHAR, &LIB_TREE::onTreeCharHook, this );
Bind( SYMBOL_PRESELECTED, &LIB_TREE::onPreselect, this );
if( m_query_ctrl )
@ -528,6 +532,23 @@ void LIB_TREE::onQueryMouseMoved( wxMouseEvent& aEvent )
}
void LIB_TREE::onTreeCharHook( wxKeyEvent& aKeyStroke )
{
onQueryCharHook( aKeyStroke );
if( aKeyStroke.GetSkipped() )
{
if( TOOL_INTERACTIVE* tool = m_adapter->GetContextMenuTool() )
{
int hotkey = aKeyStroke.GetModifiers() | aKeyStroke.GetKeyCode();
if( tool->GetManager()->GetActionManager()->RunHotKey( hotkey ) )
aKeyStroke.Skip( false );
}
}
}
void LIB_TREE::onTreeSelect( wxDataViewEvent& aEvent )
{
if( !m_inTimerEvent )

View File

@ -82,7 +82,7 @@ bool SYMBOL_EDITOR_CONTROL::Init()
auto symbolSelectedCondition =
[ editFrame ]( const SELECTION& aSel )
{
LIB_ID sel = editFrame->GetTreeLIBID();
LIB_ID sel = editFrame->GetTargetLibId();
return !sel.GetLibNickname().empty() && !sel.GetLibItemName().empty();
};
auto saveSymbolAsCondition =

View File

@ -196,6 +196,7 @@ protected:
void onTreeSelect( wxDataViewEvent& aEvent );
void onTreeActivate( wxDataViewEvent& aEvent );
void onTreeCharHook( wxKeyEvent& aEvent );
void onSize( wxSizeEvent& aEvent );
void onDetailsLink( wxHtmlLinkEvent& aEvent );