← Back to team overview

kicad-developers team mailing list archive

Re: GAL canvas behavior.

 

I think I got the right solution that would work for everyone. In case
there was nothing selected before a right click, then the selection
should be cleared after the context menu is shown (no matter whether
cancelled or used).
It is coherent with the hot keys behavior and allows the user to apply
both working methods: either select items and decide on action or
execute an action for a pointed item. I attach the patch for comments.

Cheers,
Orson

On 07/20/2017 07:22 PM, Wayne Stambaugh wrote:
> I've finally forced myself to start using the GAL canvas for new
> projects and I immediately ran into an unexpected behavior regarding
> context menus.  If I right click on an object, it gets selected and the
> context menu for that object is shown as expected.  If I change my mind
> and close the context menu with the escape key, the context menu
> disappears.  So far so good but here is where things get ugly.  The
> object from the canceled context menu is still selected so if I move the
> cursor to a different object and right click, the context menu from the
> previously (still) selected object appears and selecting a command from
> the context menu will be performed on the object at the first right
> click position rather than the object the cursor is currently over.
> This seems broken to me.  I have to hit the escape key a second time to
> deselect the initial object selection.  Is this the behavior we really
> want?  I would expect that the initial object would have been deselected
> when I aborted the context menu (or performed a command on the selected
> object) so the next right click would select the new object.  With the
> current behavior, I have to hit the escape key a second time to deselect
> the original selection.  Anyone who has been following the dev mailing
> list for any amount of time knows how much I dislike additional steps to
> accomplish a task.  This falls under that category in a big way.  Can
> this be changed to mimic the behavior of the legacy canvas?  If so, I
> will file a bug report.  If not, we need to discuss this before I am
> willing to kick the legacy canvas to the curb.
> 
> Cheers,
> 
> Wayne
> 
> _______________________________________________
> Mailing list: https://launchpad.net/~kicad-developers
> Post to     : kicad-developers@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~kicad-developers
> More help   : https://help.launchpad.net/ListHelp
> 

From 9b27fd19d88cce6fbf240a73d4e5a71e1f1555ec Mon Sep 17 00:00:00 2001
From: Maciej Suminski <maciej.suminski@xxxxxxx>
Date: Mon, 31 Jul 2017 10:17:37 +0200
Subject: [PATCH] Cancel selection if an item has been selected by right click

---
 pcbnew/tools/selection_tool.cpp | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp
index ebf93f569..b7b5bae86 100644
--- a/pcbnew/tools/selection_tool.cpp
+++ b/pcbnew/tools/selection_tool.cpp
@@ -232,6 +232,8 @@ void SELECTION_TOOL::Reset( RESET_REASON aReason )
 
 int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
 {
+    bool unselect = false;
+
     // Main loop: keep receiving events
     while( OPT_TOOL_EVENT evt = Wait() )
     {
@@ -265,9 +267,9 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
         // right click? if there is any object - show the context menu
         else if( evt->IsClick( BUT_RIGHT ) )
         {
-            bool emptySelection = m_selection.Empty();
+            unselect = m_selection.Empty();
 
-            if( emptySelection )
+            if( unselect )
                 selectPoint( evt->Position() );
 
             m_menu.ShowContextMenu( m_selection );
@@ -301,6 +303,7 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
                 else
                 {
                     m_toolMgr->InvokeTool( "pcbnew.InteractiveEdit" );
+                    unselect = true;
                 }
             }
 
@@ -320,9 +323,11 @@ int SELECTION_TOOL::Main( const TOOL_EVENT& aEvent )
             }
         }
 
-        else if( evt->IsCancel() || evt->Action() == TA_UNDO_REDO_PRE )
+        else if( evt->IsCancel() || evt->Action() == TA_UNDO_REDO_PRE
+                || ( unselect && m_toolMgr->GetCurrentToolId() == GetId() ) )
         {
             clearSelection();
+            unselect = false;
         }
 
         else if( evt->Action() == TA_CONTEXT_MENU_CLOSED )
-- 
2.13.3

Attachment: signature.asc
Description: OpenPGP digital signature


Follow ups

References