Return handled status for actions run from hotkeys
This commit is contained in:
parent
a96158e26b
commit
b6f6fc3d65
|
@ -152,8 +152,7 @@ bool ACTION_MANAGER::RunHotKey( int aHotKey ) const
|
||||||
"ACTION_MANAGER::RunHotKey Running action %s for hotkey %s", context->GetName(),
|
"ACTION_MANAGER::RunHotKey Running action %s for hotkey %s", context->GetName(),
|
||||||
KeyNameFromKeyCode( aHotKey ) );
|
KeyNameFromKeyCode( aHotKey ) );
|
||||||
|
|
||||||
m_toolMgr->RunAction( *context, true );
|
return m_toolMgr->RunAction( *context, true );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
else if( global )
|
else if( global )
|
||||||
{
|
{
|
||||||
|
@ -161,8 +160,7 @@ bool ACTION_MANAGER::RunHotKey( int aHotKey ) const
|
||||||
"ACTION_MANAGER::RunHotKey Running action: %s for hotkey %s", global->GetName(),
|
"ACTION_MANAGER::RunHotKey Running action: %s for hotkey %s", global->GetName(),
|
||||||
KeyNameFromKeyCode( aHotKey ) );
|
KeyNameFromKeyCode( aHotKey ) );
|
||||||
|
|
||||||
m_toolMgr->RunAction( *global, true );
|
return m_toolMgr->RunAction( *global, true );
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxLogTrace( kicadTraceToolStack, "ACTION_MANAGER::RunHotKey No action found for key %s",
|
wxLogTrace( kicadTraceToolStack, "ACTION_MANAGER::RunHotKey No action found for key %s",
|
||||||
|
|
|
@ -278,8 +278,9 @@ bool TOOL_MANAGER::RunAction( const std::string& aActionName, bool aNow, void* a
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TOOL_MANAGER::RunAction( const TOOL_ACTION& aAction, bool aNow, void* aParam )
|
bool TOOL_MANAGER::RunAction( const TOOL_ACTION& aAction, bool aNow, void* aParam )
|
||||||
{
|
{
|
||||||
|
bool handled = false;
|
||||||
TOOL_EVENT event = aAction.MakeEvent();
|
TOOL_EVENT event = aAction.MakeEvent();
|
||||||
|
|
||||||
// Allow to override the action parameter
|
// Allow to override the action parameter
|
||||||
|
@ -289,7 +290,7 @@ void TOOL_MANAGER::RunAction( const TOOL_ACTION& aAction, bool aNow, void* aPara
|
||||||
if( aNow )
|
if( aNow )
|
||||||
{
|
{
|
||||||
TOOL_STATE* current = m_activeState;
|
TOOL_STATE* current = m_activeState;
|
||||||
processEvent( event );
|
handled = processEvent( event );
|
||||||
setActiveState( current );
|
setActiveState( current );
|
||||||
UpdateUI( event );
|
UpdateUI( event );
|
||||||
}
|
}
|
||||||
|
@ -297,6 +298,8 @@ void TOOL_MANAGER::RunAction( const TOOL_ACTION& aAction, bool aNow, void* aPara
|
||||||
{
|
{
|
||||||
PostEvent( event );
|
PostEvent( event );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -956,22 +959,26 @@ bool TOOL_MANAGER::processEvent( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
wxLogTrace( kicadTraceToolStack, "TOOL_MANAGER::processEvent %s", aEvent.Format() );
|
wxLogTrace( kicadTraceToolStack, "TOOL_MANAGER::processEvent %s", aEvent.Format() );
|
||||||
|
|
||||||
if( dispatchHotKey( aEvent ) )
|
// First try to dispatch the action associated with the event if it is a key press event
|
||||||
return true;
|
bool handled = dispatchHotKey( aEvent );
|
||||||
|
|
||||||
bool handled = false;
|
if( !handled )
|
||||||
|
|
||||||
handled |= dispatchInternal( aEvent );
|
|
||||||
handled |= dispatchActivation( aEvent );
|
|
||||||
|
|
||||||
DispatchContextMenu( aEvent );
|
|
||||||
|
|
||||||
// Dispatch queue
|
|
||||||
while( !m_eventQueue.empty() )
|
|
||||||
{
|
{
|
||||||
TOOL_EVENT event = m_eventQueue.front();
|
// If the event is not handled through a hotkey activation, pass it to the currently
|
||||||
m_eventQueue.pop_front();
|
// running tool loops
|
||||||
processEvent( event );
|
handled |= dispatchInternal( aEvent );
|
||||||
|
handled |= dispatchActivation( aEvent );
|
||||||
|
|
||||||
|
// Open the context menu if requested by a tool
|
||||||
|
DispatchContextMenu( aEvent );
|
||||||
|
|
||||||
|
// Dispatch any remaining events in the event queue
|
||||||
|
while( !m_eventQueue.empty() )
|
||||||
|
{
|
||||||
|
TOOL_EVENT event = m_eventQueue.front();
|
||||||
|
m_eventQueue.pop_front();
|
||||||
|
processEvent( event );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxLogTrace( kicadTraceToolStack, "TOOL_MANAGER::processEvent handled: %s %s",
|
wxLogTrace( kicadTraceToolStack, "TOOL_MANAGER::processEvent handled: %s %s",
|
||||||
|
|
|
@ -122,23 +122,28 @@ public:
|
||||||
* Function RunAction()
|
* Function RunAction()
|
||||||
* Runs the specified action.
|
* Runs the specified action.
|
||||||
*
|
*
|
||||||
|
* This function will only return if the action has been handled when the action is run
|
||||||
|
* immediately (aNow = true), otherwise it will always return false.
|
||||||
|
*
|
||||||
* @param aAction is the action to be invoked.
|
* @param aAction is the action to be invoked.
|
||||||
* @param aNow decides if the action has to be run immediately or after the current coroutine
|
* @param aNow decides if the action has to be run immediately or after the current coroutine
|
||||||
* is preemptied.
|
* is preemptied.
|
||||||
* @param aParam is an optional parameter that might be used by the invoked action. Its meaning
|
* @param aParam is an optional parameter that might be used by the invoked action. Its meaning
|
||||||
* depends on the action.
|
* depends on the action.
|
||||||
|
*
|
||||||
|
* @return True if the action was handled immediately
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template <typename T>
|
||||||
void RunAction( const TOOL_ACTION& aAction, bool aNow = false, T aParam = NULL )
|
bool RunAction( const TOOL_ACTION& aAction, bool aNow = false, T aParam = NULL )
|
||||||
{
|
{
|
||||||
RunAction( aAction, aNow, reinterpret_cast<void*>( aParam ) );
|
return RunAction( aAction, aNow, reinterpret_cast<void*>( aParam ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunAction( const TOOL_ACTION& aAction, bool aNow, void* aParam );
|
bool RunAction( const TOOL_ACTION& aAction, bool aNow, void* aParam );
|
||||||
|
|
||||||
void RunAction( const TOOL_ACTION& aAction, bool aNow = false )
|
bool RunAction( const TOOL_ACTION& aAction, bool aNow = false )
|
||||||
{
|
{
|
||||||
RunAction( aAction, aNow, (void*) NULL );
|
return RunAction( aAction, aNow, (void*) NULL );
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::map<std::string, TOOL_ACTION*>& GetActions();
|
const std::map<std::string, TOOL_ACTION*>& GetActions();
|
||||||
|
|
Loading…
Reference in New Issue