kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #41848
[Patch] Another hotkey processing fix
In the current framework, if more than one global actions share the same
hotkey (even if they are not all active in the current tool manager), the
dispatcher will only choose the final action (in what seems to be
alphabetical order) to run. I think that the correct behavior should
instead be to loop through all global actions that have the hotkey until
one handles it.
The attached patch implements this change.
-Ian
From 70ee483a8184814d5be0f2be9bb7bf01b8977fc6 Mon Sep 17 00:00:00 2001
From: Ian McInerney <Ian.S.McInerney@xxxxxxxx>
Date: Fri, 9 Aug 2019 01:10:31 +0200
Subject: [PATCH] Run all matching global actions for a hotkey
---
common/tool/action_manager.cpp | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/common/tool/action_manager.cpp b/common/tool/action_manager.cpp
index 96e1eabd0..a529c1dc1 100644
--- a/common/tool/action_manager.cpp
+++ b/common/tool/action_manager.cpp
@@ -118,15 +118,16 @@ bool ACTION_MANAGER::RunHotKey( int aHotKey ) const
// Choose the action that has the highest priority on the active tools stack
// If there is none, run the global action associated with the hot key
int highestPriority = -1, priority = -1;
- const TOOL_ACTION* context = NULL; // pointer to context action of the highest priority tool
- const TOOL_ACTION* global = NULL; // pointer to global action, if there is no context action
+ const TOOL_ACTION* context = NULL; // pointer to context action of the highest priority tool
+ std::vector<const TOOL_ACTION*> global; // pointers to global actions
+ // if there is no context action
for( const TOOL_ACTION* action : actions )
{
if( action->GetScope() == AS_GLOBAL )
{
// Store the global action in case there are no context actions to run
- global = action;
+ global.emplace_back( action );
continue;
}
@@ -154,13 +155,17 @@ bool ACTION_MANAGER::RunHotKey( int aHotKey ) const
return m_toolMgr->RunAction( *context, true );
}
- else if( global )
+ else if( !global.empty() )
{
- wxLogTrace( kicadTraceToolStack,
- "ACTION_MANAGER::RunHotKey Running action: %s for hotkey %s", global->GetName(),
- KeyNameFromKeyCode( aHotKey ) );
+ for( auto act : global )
+ {
+ wxLogTrace( kicadTraceToolStack,
+ "ACTION_MANAGER::RunHotKey Running action: %s for hotkey %s", act->GetName(),
+ KeyNameFromKeyCode( aHotKey ) );
- return m_toolMgr->RunAction( *global, true );
+ if( m_toolMgr->RunAction( *act, true ) )
+ return true;
+ }
}
wxLogTrace( kicadTraceToolStack, "ACTION_MANAGER::RunHotKey No action found for key %s",
--
2.21.0
Follow ups