Cleanup event processing stuff to keep better track of "handled".
See: https://lists.launchpad.net/kicad-developers/msg41471.html .
This commit is contained in:
parent
483dc24e87
commit
30ec895c96
|
@ -489,10 +489,8 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
|
||||||
|
|
||||||
// Not handled wxEVT_CHAR must be Skipped (sent to GUI).
|
// Not handled wxEVT_CHAR must be Skipped (sent to GUI).
|
||||||
// Otherwise accelerators and shortcuts in main menu or toolbars are not seen.
|
// Otherwise accelerators and shortcuts in main menu or toolbars are not seen.
|
||||||
#ifndef __APPLE__
|
|
||||||
if( (type == wxEVT_CHAR || type == wxEVT_CHAR_HOOK) && !keyIsSpecial && !handled )
|
if( (type == wxEVT_CHAR || type == wxEVT_CHAR_HOOK) && !keyIsSpecial && !handled )
|
||||||
aEvent.Skip();
|
aEvent.Skip();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -524,8 +524,10 @@ TOOL_EVENT* TOOL_MANAGER::ScheduleWait( TOOL_BASE* aTool, const TOOL_EVENT_LIST&
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void TOOL_MANAGER::dispatchInternal( const TOOL_EVENT& aEvent )
|
bool TOOL_MANAGER::dispatchInternal( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
|
bool handled = false;
|
||||||
|
|
||||||
// iterate over active tool stack
|
// iterate over active tool stack
|
||||||
for( auto it = m_activeTools.begin(); it != m_activeTools.end(); ++it )
|
for( auto it = m_activeTools.begin(); it != m_activeTools.end(); ++it )
|
||||||
{
|
{
|
||||||
|
@ -562,10 +564,13 @@ void TOOL_MANAGER::dispatchInternal( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
// If the tool did not request the event be passed to other tools, we're done
|
// If the tool did not request the event be passed to other tools, we're done
|
||||||
if( !st->wakeupEvent.PassEvent() )
|
if( !st->wakeupEvent.PassEvent() )
|
||||||
|
{
|
||||||
|
handled = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for( auto& state : m_toolState )
|
for( auto& state : m_toolState )
|
||||||
{
|
{
|
||||||
|
@ -603,6 +608,7 @@ void TOOL_MANAGER::dispatchInternal( const TOOL_EVENT& aEvent )
|
||||||
setActiveState( st );
|
setActiveState( st );
|
||||||
st->idle = false;
|
st->idle = false;
|
||||||
st->cofunc->Call( aEvent );
|
st->cofunc->Call( aEvent );
|
||||||
|
handled = true;
|
||||||
|
|
||||||
if( !st->cofunc->Running() )
|
if( !st->cofunc->Running() )
|
||||||
finishTool( st ); // The couroutine has finished immediately?
|
finishTool( st ); // The couroutine has finished immediately?
|
||||||
|
@ -619,19 +625,17 @@ void TOOL_MANAGER::dispatchInternal( const TOOL_EVENT& aEvent )
|
||||||
if( finished )
|
if( finished )
|
||||||
break; // only the first tool gets the event
|
break; // only the first tool gets the event
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool TOOL_MANAGER::dispatchStandardEvents( const TOOL_EVENT& aEvent )
|
bool TOOL_MANAGER::dispatchHotKey( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
if( aEvent.Action() == TA_KEY_PRESSED )
|
if( aEvent.Action() == TA_KEY_PRESSED )
|
||||||
{
|
return m_actionMgr->RunHotKey( aEvent.Modifier() | aEvent.KeyCode() );
|
||||||
// Check if there is a hotkey associated
|
|
||||||
if( m_actionMgr->RunHotKey( aEvent.Modifier() | aEvent.KeyCode() ) )
|
|
||||||
return false; // hotkey event was handled so it does not go any further
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -775,10 +779,12 @@ TOOL_MANAGER::ID_LIST::iterator TOOL_MANAGER::finishTool( TOOL_STATE* aState )
|
||||||
|
|
||||||
bool TOOL_MANAGER::ProcessEvent( const TOOL_EVENT& aEvent )
|
bool TOOL_MANAGER::ProcessEvent( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
bool hotkey_handled = processEvent( aEvent );
|
bool handled = processEvent( aEvent );
|
||||||
|
|
||||||
if( TOOL_STATE* active = GetCurrentToolState() )
|
TOOL_STATE* activeTool = GetCurrentToolState();
|
||||||
setActiveState( active );
|
|
||||||
|
if( activeTool )
|
||||||
|
setActiveState( activeTool );
|
||||||
|
|
||||||
if( m_view && m_view->IsDirty() )
|
if( m_view && m_view->IsDirty() )
|
||||||
{
|
{
|
||||||
|
@ -791,7 +797,7 @@ bool TOOL_MANAGER::ProcessEvent( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
UpdateUI( aEvent );
|
UpdateUI( aEvent );
|
||||||
|
|
||||||
return hotkey_handled;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -925,12 +931,14 @@ void TOOL_MANAGER::applyViewControls( TOOL_STATE* aState )
|
||||||
|
|
||||||
bool TOOL_MANAGER::processEvent( const TOOL_EVENT& aEvent )
|
bool TOOL_MANAGER::processEvent( const TOOL_EVENT& aEvent )
|
||||||
{
|
{
|
||||||
// Early dispatch of events destined for the TOOL_MANAGER
|
if( dispatchHotKey( aEvent ) )
|
||||||
if( !dispatchStandardEvents( aEvent ) )
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
dispatchInternal( aEvent );
|
bool handled = false;
|
||||||
dispatchActivation( aEvent );
|
|
||||||
|
handled |= dispatchInternal( aEvent );
|
||||||
|
handled |= dispatchActivation( aEvent );
|
||||||
|
|
||||||
DispatchContextMenu( aEvent );
|
DispatchContextMenu( aEvent );
|
||||||
|
|
||||||
// Dispatch queue
|
// Dispatch queue
|
||||||
|
@ -941,7 +949,7 @@ bool TOOL_MANAGER::processEvent( const TOOL_EVENT& aEvent )
|
||||||
processEvent( event );
|
processEvent( event );
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -764,7 +764,7 @@ int SCH_EDITOR_CONTROL::Redo( const TOOL_EVENT& aEvent )
|
||||||
bool SCH_EDITOR_CONTROL::doCopy()
|
bool SCH_EDITOR_CONTROL::doCopy()
|
||||||
{
|
{
|
||||||
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
EE_SELECTION_TOOL* selTool = m_toolMgr->GetTool<EE_SELECTION_TOOL>();
|
||||||
EE_SELECTION& selection = selTool->GetSelection();
|
EE_SELECTION& selection = selTool->RequestSelection();
|
||||||
|
|
||||||
if( !selection.GetSize() )
|
if( !selection.GetSize() )
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -382,15 +382,15 @@ private:
|
||||||
* Function dispatchInternal
|
* Function dispatchInternal
|
||||||
* Passes an event at first to the active tools, then to all others.
|
* Passes an event at first to the active tools, then to all others.
|
||||||
*/
|
*/
|
||||||
void dispatchInternal( const TOOL_EVENT& aEvent );
|
bool dispatchInternal( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function dispatchStandardEvents()
|
* Function dispatchStandardEvents()
|
||||||
* Handles specific events, that are intended for TOOL_MANAGER rather than tools.
|
* Handles specific events, that are intended for TOOL_MANAGER rather than tools.
|
||||||
* @param aEvent is the event to be processed.
|
* @param aEvent is the event to be processed.
|
||||||
* @return False if the event was processed and should not go any further.
|
* @return true if the event was processed and should not go any further.
|
||||||
*/
|
*/
|
||||||
bool dispatchStandardEvents( const TOOL_EVENT& aEvent );
|
bool dispatchHotKey( const TOOL_EVENT& aEvent );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function dispatchActivation()
|
* Function dispatchActivation()
|
||||||
|
|
Loading…
Reference in New Issue