Add action to focus tree searches

The default hotkey is Ctrl+L, as this is not bound by
default in the FP or symbol editor, and it is the hotkey
that is used to focus the address bar in web browsers,
which is a similar kind of action.
This commit is contained in:
John Beard 2024-05-05 04:17:26 +08:00
parent f73c190da8
commit 4dd049ee8f
12 changed files with 60 additions and 0 deletions

View File

@ -711,6 +711,12 @@ bool SYMBOL_EDIT_FRAME::IsSymbolTreeShown() const
}
void SYMBOL_EDIT_FRAME::FocusSearchTreeInput()
{
m_treePane->GetLibTree()->FocusSearchFieldIfExists();
}
void SYMBOL_EDIT_FRAME::FreezeLibraryTree()
{
m_treePane->Freeze();

View File

@ -185,6 +185,7 @@ public:
void ToggleProperties() override;
bool IsSymbolTreeShown() const;
void FocusSearchTreeInput();
void FreezeLibraryTree();
void ThawLibraryTree();

View File

@ -289,6 +289,12 @@ TOOL_ACTION EE_ACTIONS::hideSymbolTree( TOOL_ACTION_ARGS()
.FriendlyName( _( "Hide Symbol Tree" ) )
.Icon( BITMAPS::search_tree ) );
TOOL_ACTION EE_ACTIONS::symbolTreeSearch( TOOL_ACTION_ARGS()
.Name( "eeschema.SymbolLibraryControl.symbolTreeSearch" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Focus Symbol Tree Search Field" ) )
.DefaultHotkey( MD_CTRL + 'L' ) );
TOOL_ACTION EE_ACTIONS::exportSymbolView( TOOL_ACTION_ARGS()
.Name( "eeschema.SymbolLibraryControl.exportSymbolView" )
.Scope( AS_GLOBAL )

View File

@ -251,6 +251,7 @@ public:
static TOOL_ACTION showPinNumbers;
static TOOL_ACTION showSymbolTree;
static TOOL_ACTION hideSymbolTree;
static TOOL_ACTION symbolTreeSearch;
static TOOL_ACTION drawSheetOnClipboard;
static TOOL_ACTION importGraphics;
static TOOL_ACTION exportSymbolView;

View File

@ -550,6 +550,24 @@ int SYMBOL_EDITOR_CONTROL::ToggleSymbolTree( const TOOL_EVENT& aEvent )
}
int SYMBOL_EDITOR_CONTROL::SymbolTreeSearch( const TOOL_EVENT& aEvent )
{
if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) )
{
SYMBOL_EDIT_FRAME& sym_edit_frame = static_cast<SYMBOL_EDIT_FRAME&>( *m_frame );
if( !sym_edit_frame.IsSymbolTreeShown() )
{
wxCommandEvent dummy;
sym_edit_frame.OnToggleSymbolTree( dummy );
}
sym_edit_frame.FocusSearchTreeInput();
}
return 0;
}
int SYMBOL_EDITOR_CONTROL::ToggleProperties( const TOOL_EVENT& aEvent )
{
if( m_frame->IsType( FRAME_SCH_SYMBOL_EDITOR ) )
@ -814,6 +832,7 @@ void SYMBOL_EDITOR_CONTROL::setTransitions()
Go( &SYMBOL_EDITOR_CONTROL::UnpinLibrary, ACTIONS::unpinLibrary.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::ToggleSymbolTree, EE_ACTIONS::showSymbolTree.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::ToggleSymbolTree, EE_ACTIONS::hideSymbolTree.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::SymbolTreeSearch, EE_ACTIONS::symbolTreeSearch.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::ToggleSyncedPinsMode, EE_ACTIONS::toggleSyncedPinsMode.MakeEvent() );
Go( &SYMBOL_EDITOR_CONTROL::ToggleProperties, ACTIONS::showProperties.MakeEvent() );

View File

@ -69,6 +69,7 @@ public:
int PinLibrary( const TOOL_EVENT& aEvent );
int UnpinLibrary( const TOOL_EVENT& aEvent );
int ToggleSymbolTree( const TOOL_EVENT& aEvent );
int SymbolTreeSearch( const TOOL_EVENT& aEvent );
int ToggleProperties( const TOOL_EVENT& aEvent );
int ToggleSyncedPinsMode( const TOOL_EVENT& aEvent );

View File

@ -397,6 +397,12 @@ void FOOTPRINT_EDIT_FRAME::ToggleSearchTree()
}
void FOOTPRINT_EDIT_FRAME::FocusSearchTreeInput()
{
m_treePane->FocusSearchFieldIfExists();
}
void FOOTPRINT_EDIT_FRAME::ToggleLayersManager()
{
FOOTPRINT_EDITOR_SETTINGS* settings = GetSettings();

View File

@ -140,6 +140,7 @@ public:
bool IsSearchTreeShown() const;
void ToggleSearchTree();
void FocusSearchTreeInput();
void ToggleLayersManager();
/**

View File

@ -670,6 +670,16 @@ int FOOTPRINT_EDITOR_CONTROL::ToggleFootprintTree( const TOOL_EVENT& aEvent )
}
int FOOTPRINT_EDITOR_CONTROL::FootprintTreeSearch( const TOOL_EVENT& aEvent )
{
if (!m_frame->IsSearchTreeShown()) {
m_frame->ToggleSearchTree();
}
m_frame->FocusSearchTreeInput();
return 0;
}
int FOOTPRINT_EDITOR_CONTROL::ToggleLayersManager( const TOOL_EVENT& aEvent )
{
m_frame->ToggleLayersManager();
@ -857,6 +867,7 @@ void FOOTPRINT_EDITOR_CONTROL::setTransitions()
Go( &FOOTPRINT_EDITOR_CONTROL::UnpinLibrary, ACTIONS::unpinLibrary.MakeEvent() );
Go( &FOOTPRINT_EDITOR_CONTROL::ToggleFootprintTree, PCB_ACTIONS::showFootprintTree.MakeEvent() );
Go( &FOOTPRINT_EDITOR_CONTROL::ToggleFootprintTree, PCB_ACTIONS::hideFootprintTree.MakeEvent() );
Go( &FOOTPRINT_EDITOR_CONTROL::FootprintTreeSearch, PCB_ACTIONS::footprintTreeSearch.MakeEvent() );
Go( &FOOTPRINT_EDITOR_CONTROL::Properties, PCB_ACTIONS::footprintProperties.MakeEvent() );
Go( &FOOTPRINT_EDITOR_CONTROL::DefaultPadProperties, PCB_ACTIONS::defaultPadProperties.MakeEvent() );
Go( &FOOTPRINT_EDITOR_CONTROL::ToggleLayersManager, PCB_ACTIONS::showLayersManager.MakeEvent() );

View File

@ -68,6 +68,7 @@ public:
int PinLibrary( const TOOL_EVENT& aEvent );
int UnpinLibrary( const TOOL_EVENT& aEvent );
int ToggleFootprintTree( const TOOL_EVENT& aEvent );
int FootprintTreeSearch( const TOOL_EVENT& aEvent );
int ToggleLayersManager( const TOOL_EVENT& aEvent );
int ToggleProperties( const TOOL_EVENT& aEvent );
int Properties( const TOOL_EVENT& aEvent );

View File

@ -697,6 +697,12 @@ TOOL_ACTION PCB_ACTIONS::hideFootprintTree( TOOL_ACTION_ARGS()
.FriendlyName( _( "Hide Footprint Tree" ) )
.Icon( BITMAPS::search_tree ) );
TOOL_ACTION PCB_ACTIONS::footprintTreeSearch( TOOL_ACTION_ARGS()
.Name( "pcbnew.ModuleEditor.footprintTreeSearch" )
.Scope( AS_GLOBAL )
.FriendlyName( _( "Focus the Footprint Tree Search Field" ) )
.DefaultHotkey( MD_CTRL + 'L' ) );
TOOL_ACTION PCB_ACTIONS::newFootprint( TOOL_ACTION_ARGS()
.Name( "pcbnew.ModuleEditor.newFootprint" )
.Scope( AS_GLOBAL )

View File

@ -448,6 +448,7 @@ public:
static TOOL_ACTION showFootprintTree;
static TOOL_ACTION hideFootprintTree;
static TOOL_ACTION footprintTreeSearch;
// We don't use ACTION::new here because we need to distinguish between New Library
// and New Footprint.