From 62cfd2730e68dce022c061c8d4bed1e38a9e17e7 Mon Sep 17 00:00:00 2001 From: bkuker Date: Sun, 6 Jan 2013 10:23:53 -0500 Subject: [PATCH 1/2] Trigger componentClicked with an empty list if no component is picked by a clock on the 3d model --- .../net/sf/openrocket/gui/figure3d/RocketFigure3d.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/net/sf/openrocket/gui/figure3d/RocketFigure3d.java b/core/src/net/sf/openrocket/gui/figure3d/RocketFigure3d.java index febe7b5fd..6ac1b7892 100644 --- a/core/src/net/sf/openrocket/gui/figure3d/RocketFigure3d.java +++ b/core/src/net/sf/openrocket/gui/figure3d/RocketFigure3d.java @@ -267,13 +267,17 @@ public class RocketFigure3d extends JPanel implements GLEventListener { gl.glDisable(GLLightingFunc.GL_LIGHTING); final RocketComponent picked = rr.pick(drawable, configuration, pickPoint, pickEvent.isShiftDown() ? selection : null); - if (csl != null && picked != null) { + if (csl != null) { final MouseEvent e = pickEvent; SwingUtilities.invokeLater(new Runnable() { @Override public void run() { - csl.componentClicked(new RocketComponent[] { picked }, - e); + if ( picked == null ){ + log.debug("unselecting"); + csl.componentClicked(new RocketComponent[] { }, e); + } else { + csl.componentClicked(new RocketComponent[] { picked }, e); + } } }); From 3fe7370e0854f2993f0b623037904e367bed9b4f Mon Sep 17 00:00:00 2001 From: bkuker Date: Sun, 6 Jan 2013 10:26:36 -0500 Subject: [PATCH 2/2] Set null selection path when nothing is clicked. Fix a bug that wasn't updating the 3d selection when unselecting --- core/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/core/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java b/core/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java index 910752133..c71237a1d 100644 --- a/core/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java +++ b/core/src/net/sf/openrocket/gui/scalefigure/RocketPanel.java @@ -530,8 +530,10 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change private void handleComponentClick(RocketComponent[] clicked, MouseEvent event){ // If no component is clicked, do nothing - if (clicked.length == 0) + if (clicked.length == 0){ + selectionModel.setSelectionPath(null); return; + } // Check whether the currently selected component is in the clicked components. TreePath path = selectionModel.getSelectionPath(); @@ -827,6 +829,7 @@ public class RocketPanel extends JPanel implements TreeSelectionListener, Change TreePath[] paths = selectionModel.getSelectionPaths(); if (paths == null) { figure.setSelection(null); + figure3d.setSelection(null); return; }