X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.diagram%2Fsrc%2Forg%2Fsimantics%2Fdiagram%2Fparticipant%2FConnectTool2.java;h=7d3a5a4005078f314f96d49b931978eabb5ad4c5;hp=b77a2894714b72512c5925ea7b6379fc6e17c382;hb=13ff25bbcaaf3f36293a931403486ccc3897c9a6;hpb=ce7ffc15e6ebcdb21089ac862aa5af01da89d454 diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/ConnectTool2.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/ConnectTool2.java index b77a28947..7d3a5a400 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/ConnectTool2.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/participant/ConnectTool2.java @@ -90,6 +90,7 @@ import org.simantics.scenegraph.g2d.events.KeyEvent.KeyPressedEvent; import org.simantics.scenegraph.g2d.events.MouseEvent; import org.simantics.scenegraph.g2d.events.MouseEvent.MouseButtonEvent; import org.simantics.scenegraph.g2d.events.MouseEvent.MouseButtonPressedEvent; +import org.simantics.scenegraph.g2d.events.MouseEvent.MouseButtonReleasedEvent; import org.simantics.scenegraph.g2d.events.MouseEvent.MouseMovedEvent; import org.simantics.scenegraph.g2d.events.command.CommandEvent; import org.simantics.scenegraph.g2d.events.command.Commands; @@ -520,6 +521,10 @@ public class ConnectTool2 extends AbstractMode { if (me instanceof MouseButtonPressedEvent) return processMouseButtonPress((MouseButtonPressedEvent) me); + // #7653: Support creating connections between terminals without lifting mouse button in between. + if (me instanceof MouseButtonReleasedEvent) + return processMouseButtonRelease((MouseButtonReleasedEvent) me); + return false; } @@ -662,15 +667,7 @@ public class ConnectTool2 extends AbstractMode { if (snapAdvisor != null) snapAdvisor.snap(mouseCanvasPos); - if (isEndTerminalDefined() && connectionJudgment != null) { - // Clicked on an allowed end terminal. End connection & end mode. - createConnection(); - remove(); - return true; - } else if (lastRouteGraphTarget != null && attachToConnectionJudgement != null) { - lastRouteGraphTarget.getNode().showBranchPoint(null); - attachToConnection(); - remove(); + if (tryEndConnection()) { return true; } else { // Finish connection in thin air only if the @@ -710,6 +707,33 @@ public class ConnectTool2 extends AbstractMode { return false; } + private int mouseLeftReleaseCount = 0; + + protected boolean processMouseButtonRelease(MouseButtonReleasedEvent me) { + if (me.button == MouseEvent.LEFT_BUTTON + && ++mouseLeftReleaseCount == 1) { + return tryEndConnection(); + } + return false; + } + + /** + * @return true if connection was successfully ended + */ + private boolean tryEndConnection() { + if (isEndTerminalDefined() && connectionJudgment != null) { + createConnection(); + remove(); + return true; + } else if (lastRouteGraphTarget != null && attachToConnectionJudgement != null) { + lastRouteGraphTarget.getNode().showBranchPoint(null); + attachToConnection(); + remove(); + return true; + } + return false; + } + private void attachToConnection() { ConnectionJudgement judgment = this.attachToConnectionJudgement; if (judgment == null) {