Commit 875c0f70 authored by Maciej Suminski's avatar Maciej Suminski

Modified InvokeTool(), so besides resetting the tool, it also send an ActivateTool event.

Added generation of CancelTool event upon ESC key press.
Minor bugfix.
parent 1057d5a5
...@@ -237,9 +237,16 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent ) ...@@ -237,9 +237,16 @@ void TOOL_DISPATCHER::DispatchWxEvent( wxEvent& aEvent )
int mods = decodeModifiers( ke ); int mods = decodeModifiers( ke );
if( type == wxEVT_KEY_UP ) if( type == wxEVT_KEY_UP )
evt = TOOL_EVENT( TC_Keyboard, TA_KeyUp, key | mods ); {
if( key == WXK_ESCAPE )
evt = TOOL_EVENT( TC_Command, TA_CancelTool );
else
evt = TOOL_EVENT( TC_Keyboard, TA_KeyUp, key | mods );
}
else else
{
evt = TOOL_EVENT( TC_Keyboard, TA_KeyDown, key | mods ); evt = TOOL_EVENT( TC_Keyboard, TA_KeyDown, key | mods );
}
} }
if( evt ) if( evt )
...@@ -263,8 +270,5 @@ void TOOL_DISPATCHER::DispatchWxCommand( wxCommandEvent &aEvent ) ...@@ -263,8 +270,5 @@ void TOOL_DISPATCHER::DispatchWxCommand( wxCommandEvent &aEvent )
} }
if( activateTool ) if( activateTool )
{ m_toolMgr->InvokeTool( toolName );
TOOL_EVENT evt( TC_Command, TA_ActivateTool, toolName );
m_toolMgr->ProcessEvent( evt );
}
} }
...@@ -98,6 +98,9 @@ void TOOL_MANAGER::InvokeTool( TOOL_ID aToolId ) ...@@ -98,6 +98,9 @@ void TOOL_MANAGER::InvokeTool( TOOL_ID aToolId )
if( tool && tool->GetType() == TOOL_Interactive ) if( tool && tool->GetType() == TOOL_Interactive )
static_cast<TOOL_INTERACTIVE*>( tool )->Reset(); static_cast<TOOL_INTERACTIVE*>( tool )->Reset();
TOOL_EVENT evt( TC_Command, TA_ActivateTool, tool->GetName() );
ProcessEvent( evt );
} }
...@@ -105,8 +108,8 @@ void TOOL_MANAGER::InvokeTool( const std::string& aName ) ...@@ -105,8 +108,8 @@ void TOOL_MANAGER::InvokeTool( const std::string& aName )
{ {
TOOL_BASE* tool = FindTool( aName ); TOOL_BASE* tool = FindTool( aName );
if( tool && tool->GetType() == TOOL_Interactive ) if( tool )
static_cast<TOOL_INTERACTIVE*>( tool )->Reset(); InvokeTool( tool->GetId() );
} }
...@@ -169,7 +172,10 @@ void TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent ) ...@@ -169,7 +172,10 @@ void TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent )
st->waitEvents.clear(); st->waitEvents.clear();
st->cofunc->Resume(); st->cofunc->Resume();
if( !st->cofunc->Running() ) if( !st->cofunc->Running() )
{
delete st->cofunc; delete st->cofunc;
st->cofunc = NULL;
}
} }
} }
else else
...@@ -194,7 +200,10 @@ void TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent ) ...@@ -194,7 +200,10 @@ void TOOL_MANAGER::dispatchInternal( TOOL_EVENT& aEvent )
st->cofunc->Call( aEvent ); st->cofunc->Call( aEvent );
if( !st->cofunc->Running() ) if( !st->cofunc->Running() )
{
delete st->cofunc; delete st->cofunc;
st->cofunc = NULL;
}
} }
} }
} }
...@@ -218,7 +227,7 @@ bool TOOL_MANAGER::ProcessEvent( TOOL_EVENT& aEvent ) ...@@ -218,7 +227,7 @@ bool TOOL_MANAGER::ProcessEvent( TOOL_EVENT& aEvent )
st->contextMenuTrigger = CMENU_OFF; st->contextMenuTrigger = CMENU_OFF;
GetEditFrame()->PopupMenu( st->contextMenu->GetMenu() ); GetEditFrame()->PopupMenu( st->contextMenu->GetMenu() );
TOOL_EVENT evt ( TC_Command, TA_ContextMenuChoice ); TOOL_EVENT evt( TC_Command, TA_ContextMenuChoice );
dispatchInternal( evt ); dispatchInternal( evt );
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment