Skip to content

Commit 8ca02d0

Browse files
committed
Bug fix: Handle selection state with respect to tools properly.
Specifically when creating, editing or selecting links modules should be deselected at the start of the change not at the end (the latter is the current, confusing, indirect behaviour).
1 parent 2e9d0b0 commit 8ca02d0

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

src/com/modsim/gui/view/ViewUtil.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ public void mousePressed(MouseEvent e) {
277277
else {
278278
Port p = screenSpace_portAt(e.getX(), e.getY());
279279

280+
Main.selection.clear();
281+
280282
//Link behaviour
281283
if (p != null) {
282284
tool = new MakeLinkTool();
@@ -408,7 +410,8 @@ public void keyPressed(KeyEvent e) {
408410
}
409411
}
410412
// Delete selection
411-
else if (e.getKeyCode() == KeyEvent.VK_DELETE) {
413+
else if (e.getKeyCode() == KeyEvent.VK_DELETE
414+
&& !Main.selection.isEmpty()) {
412415
Main.selection.deleteAll();
413416
}
414417
// Pass to tool

src/com/modsim/tools/MakeLinkTool.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ public void paintWorld(Graphics2D g) {
9494
public boolean startLink(int x, int y) {
9595
source = ViewUtil.screenSpace_portAt(x, y);
9696
if (source != null) {
97-
working = true;
97+
Main.selection.clear();
98+
99+
working = true;
98100
start = new Vec2(x, y);
99101
curve = new BezierPath();
100102

0 commit comments

Comments
 (0)