From 2f3ca60c5e1e2abf486ea2e74bc88ad7cfe2c8b3 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 4 Dec 2020 10:25:05 +0100 Subject: [PATCH] Pcbnew, modifiers for left click behavior: re-add highlight net option. Due to last changes fixing the ALT key problems, the highlight net is CTRL+SHIFT + left click on Windows and Linux CTRL+ALT + left click on OSX Fixes #6595 https://gitlab.com/kicad/code/kicad/issues/6595 --- pcbnew/tools/selection_tool.cpp | 87 ++++++++++++++++++++++++++------- 1 file changed, 69 insertions(+), 18 deletions(-) diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index 96f2a3e82d..039637da87 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -212,38 +212,89 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent ) { bool dragAlwaysSelects = getEditFrame()->GetDragSelects(); TRACK_DRAG_ACTION dragAction = getEditFrame()->Settings().m_TrackDragAction; - m_additive = m_subtractive = m_exclusive_or = false; + + // on left click, a selection is made, depending on modifiers ALT, SHIFT, CTRL: + // Due to the fact ALT key modifier cannot be useed freely on Winows and Linux, + // actions are different on OSX and others OS + // Especially, ALT key cannot be used to force showing the full selection choice + // context menu (the menu is immediately closed on Windows ) + // + // No modifier = select items and deselect previous selection + // ALT (on OSX) = skip heuristic and show full selection choice + // ALT (on others) = exclusive OR of selected items (inverse selection) + // + // CTRL (on OSX) = exclusive OR of selected items (inverse selection) + // CTRL (on others) = skip heuristic and show full selection choice + // + // SHIFT = add selected items to the current selection + // + // CTRL+SHIFT (on OSX) = remove selected items to the current selection + // CTRL+SHIFT (on others) = highlight net + // + // CTRL+ALT (on OSX) = highlight net + // CTRL+ALT (on others) = do nothing (same as no modifier) + // + // SHIFT+ALT (on OSX) = do nothing (same as no modifier) + // SHIFT+ALT (on others) = remove selected items to the current selection #ifdef __WXOSX_MAC__ - if( evt->Modifier( MD_CTRL ) && evt->Modifier( MD_SHIFT ) ) - m_subtractive = true; - else if( evt->Modifier( MD_SHIFT ) ) - m_additive = true; - else if( evt->Modifier( MD_CTRL ) ) - m_exclusive_or = true; + m_subtractive = evt->Modifier( MD_CTRL ) && + evt->Modifier( MD_SHIFT ) && + !evt->Modifier( MD_ALT ); - m_skip_heuristics = evt->Modifier( MD_ALT ); + m_additive = evt->Modifier( MD_SHIFT ) && + !evt->Modifier( MD_CTRL ) && + !evt->Modifier( MD_ALT ); + + m_exclusive_or = evt->Modifier( MD_CTRL ) && + !evt->Modifier( MD_SHIFT ) && + !evt->Modifier( MD_ALT ); + + m_skip_heuristics = evt->Modifier( MD_ALT ) && + !evt->Modifier( MD_SHIFT ) && + !evt->Modifier( MD_CTRL ); + + bool highlight_modifier = evt->Modifier( MD_CTRL ) + && evt->Modifier( MD_ALT ) + && !evt->Modifier( MD_SHIFT ); #else - if( evt->Modifier( MD_ALT ) && evt->Modifier( MD_SHIFT ) ) - m_subtractive = true; - else if( evt->Modifier( MD_SHIFT ) ) - m_additive = true; - else if( evt->Modifier( MD_ALT ) ) - m_exclusive_or = true; + m_subtractive = evt->Modifier( MD_ALT ) && + evt->Modifier( MD_SHIFT ) && + !evt->Modifier( MD_CTRL ); + + m_additive = evt->Modifier( MD_SHIFT ) && + !evt->Modifier( MD_ALT ) && + !evt->Modifier( MD_CTRL ); + + m_exclusive_or = evt->Modifier( MD_ALT ) && + !evt->Modifier( MD_SHIFT ) && + !evt->Modifier( MD_CTRL ); // Cannot use the Alt key on windows or the disambiguation context menu is immediately // dismissed rendering it useless. - m_skip_heuristics = evt->Modifier( MD_CTRL ); + m_skip_heuristics = evt->Modifier( MD_CTRL ) && + !evt->Modifier( MD_SHIFT ) && + !evt->Modifier( MD_ALT ); + + bool highlight_modifier = evt->Modifier( MD_CTRL ) + && evt->Modifier( MD_SHIFT ) + && !evt->Modifier( MD_ALT ); #endif bool modifier_enabled = m_subtractive || m_additive || m_exclusive_or; + PCB_BASE_FRAME* frame = getEditFrame(); + bool brd_editor = frame && frame->IsType( FRAME_PCB_EDITOR ); // Single click? Select single object if( evt->IsClick( BUT_LEFT ) ) { - m_frame->FocusOnItem( nullptr ); - - selectPoint( evt->Position() ); + if( highlight_modifier && brd_editor ) + m_toolMgr->RunAction( PCB_ACTIONS::highlightNet, true ); + else + { + m_frame->FocusOnItem( nullptr ); + selectPoint( evt->Position() ); + } } else if( evt->IsClick( BUT_RIGHT ) ) {