From 03f74c87a1b84f65ca1c39de8f36f1810612e91b Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Tue, 11 Feb 2020 07:12:36 -0800 Subject: [PATCH] Update immediate mode location and restart wires The immediate action option clears (or not) the position of the events. We use this to determine if the command should start at the given position or merely activate the tool. This was being checked in the menu options, which only activated for tool commands in the context menu. Moving to the process event, we catch hotkeys as well. This also restores the previous logic in eeschema that used a static variable for storing wires rather than the private class variable. Starting the draw event now picks up from the existing wires when activated in immediate mode. Fixes #3891 | https://gitlab.com/kicad/code/kicad/issues/3891 --- common/tool/action_menu.cpp | 13 ------------- common/tool/tool_manager.cpp | 19 ++++++++++++++++--- eeschema/tools/sch_line_wire_bus_tool.cpp | 4 ++++ 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/common/tool/action_menu.cpp b/common/tool/action_menu.cpp index 945a09e1a3..836cf40db8 100644 --- a/common/tool/action_menu.cpp +++ b/common/tool/action_menu.cpp @@ -448,11 +448,8 @@ void ACTION_MENU::OnMenuEvent( wxMenuEvent& aEvent ) // clients that don't supply a tool will have to check GetSelected() themselves if( evt && m_tool ) { - wxLogTrace( kicadTraceToolStack, "ACTION_MENU::OnMenuEvent %s", evt->Format() ); - TOOL_MANAGER* toolMgr = m_tool->GetManager(); - // Pass the position the menu was opened from into the generated event if it is a select event if( type == wxEVT_COMMAND_MENU_SELECTED ) evt->SetMousePosition( g_menu_open_position ); @@ -462,16 +459,6 @@ void ACTION_MENU::OnMenuEvent( wxMenuEvent& aEvent ) if( g_last_menu_highlighted_id == aEvent.GetId() && !m_isContextMenu ) evt->SetHasPosition( false ); - if( toolMgr->GetEditFrame() && !toolMgr->GetEditFrame()->GetDoImmediateActions() ) - { - // An tool-selection-event has no position - if( evt->GetCommandStr().is_initialized() - && evt->GetCommandStr().get() != toolMgr->GetEditFrame()->CurrentToolName() ) - { - evt->SetHasPosition( false ); - } - } - if( m_tool->GetManager() ) m_tool->GetManager()->ProcessEvent( *evt ); } diff --git a/common/tool/tool_manager.cpp b/common/tool/tool_manager.cpp index a04f03c37d..ca6544c2f1 100644 --- a/common/tool/tool_manager.cpp +++ b/common/tool/tool_manager.cpp @@ -1082,13 +1082,26 @@ bool TOOL_MANAGER::processEvent( const TOOL_EVENT& aEvent ) if( !handled ) { + TOOL_EVENT mod_event( aEvent ); + + // Only immediate actions get the position. Otherwise clear for tool activation + if( GetEditFrame() && !GetEditFrame()->GetDoImmediateActions() ) + { + // An tool-selection-event has no position + if( mod_event.GetCommandStr().is_initialized() + && mod_event.GetCommandStr().get() != GetEditFrame()->CurrentToolName() ) + { + mod_event.SetHasPosition( false ); + } + } + // If the event is not handled through a hotkey activation, pass it to the currently // running tool loops - handled |= dispatchInternal( aEvent ); - handled |= dispatchActivation( aEvent ); + handled |= dispatchInternal( mod_event ); + handled |= dispatchActivation( mod_event ); // Open the context menu if requested by a tool - DispatchContextMenu( aEvent ); + DispatchContextMenu( mod_event ); // Dispatch any remaining events in the event queue while( !m_eventQueue.empty() ) diff --git a/eeschema/tools/sch_line_wire_bus_tool.cpp b/eeschema/tools/sch_line_wire_bus_tool.cpp index 18619ca8ad..25cbd9f0f7 100644 --- a/eeschema/tools/sch_line_wire_bus_tool.cpp +++ b/eeschema/tools/sch_line_wire_bus_tool.cpp @@ -481,6 +481,10 @@ int SCH_LINE_WIRE_BUS_TOOL::doDrawSegments( const std::string& aTool, int aType if( m_busUnfold.label ) m_selectionTool->AddItemToSel( m_busUnfold.label, true ); + // Continue the existing wires if we've started (usually by immediate action preference) + if( !m_wires.empty() ) + segment = m_wires.back(); + // Main loop: keep receiving events while( TOOL_EVENT* evt = Wait() ) {