Don't prevent immediate actions while router active

Immediate actions that can take place are useful.  We should only be
preventing immediate actions while actively routing or dragging

Fixes https://gitlab.com/kicad/code/kicad/issues/12311
This commit is contained in:
Seth Hillbrand 2022-08-30 10:28:56 -07:00
parent 39ac58ea33
commit 91fbb5c957
4 changed files with 23 additions and 3 deletions

View File

@ -241,6 +241,13 @@ bool TOOL_EVENT::IsMoveTool() const
} }
bool TOOL_EVENT::IsEditorTool() const
{
return ( m_commandStr
&& m_commandStr.value().find( "InteractiveEdit" ) != GetCommandStr()->npos );
}
bool TOOL_EVENT::IsSimulator() const bool TOOL_EVENT::IsSimulator() const
{ {
return ( m_commandStr && m_commandStr.value().find( "Simulation" ) != GetCommandStr()->npos ); return ( m_commandStr && m_commandStr.value().find( "Simulation" ) != GetCommandStr()->npos );

View File

@ -421,6 +421,13 @@ public:
*/ */
bool IsMoveTool() const; bool IsMoveTool() const;
/**
* Indicate if the event is asking for an editor tool.
*
* Used to allow deleting an element without de-activating the current tool.
*/
bool IsEditorTool() const;
/** /**
* Indicate if the event is from the simulator. * Indicate if the event is from the simulator.
*/ */

View File

@ -1522,7 +1522,7 @@ int ROUTER_TOOL::MainLoop( const TOOL_EVENT& aEvent )
} }
else if( evt->IsActivate() ) else if( evt->IsActivate() )
{ {
if( evt->IsMoveTool() ) if( evt->IsMoveTool() || evt->IsEditorTool() )
{ {
// leave ourselves on the stack so we come back after the move // leave ourselves on the stack so we come back after the move
break; break;

View File

@ -264,12 +264,11 @@ bool EDIT_TOOL::invokeInlineRouter( int aDragMode )
} }
bool EDIT_TOOL::isRouterActive() const bool EDIT_TOOL::isRouterActive() const
{ {
ROUTER_TOOL* router = m_toolMgr->GetTool<ROUTER_TOOL>(); ROUTER_TOOL* router = m_toolMgr->GetTool<ROUTER_TOOL>();
return router && router->IsToolActive(); return router && router->RoutingInProgress();
} }
@ -1377,12 +1376,17 @@ int EDIT_TOOL::Flip( const TOOL_EVENT& aEvent )
int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent ) int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
{ {
PCB_BASE_EDIT_FRAME* editFrame = getEditFrame<PCB_BASE_EDIT_FRAME>();
if( isRouterActive() ) if( isRouterActive() )
{ {
m_toolMgr->RunAction( PCB_ACTIONS::routerUndoLastSegment, true ); m_toolMgr->RunAction( PCB_ACTIONS::routerUndoLastSegment, true );
return 0; return 0;
} }
std::string tool = aEvent.GetCommandStr().value();
editFrame->PushTool( tool );
std::vector<BOARD_ITEM*> lockedItems; std::vector<BOARD_ITEM*> lockedItems;
Activate(); Activate();
@ -1422,6 +1426,7 @@ int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
{ {
wxBell(); wxBell();
canvas()->Refresh(); canvas()->Refresh();
editFrame->PopTool( tool );
return 0; return 0;
} }
@ -1617,6 +1622,7 @@ int EDIT_TOOL::Remove( const TOOL_EVENT& aEvent )
else else
m_commit->Push( _( "Delete" ) ); m_commit->Push( _( "Delete" ) );
editFrame->PopTool( tool );
return 0; return 0;
} }