diff options
Diffstat (limited to 'src/jcgp/gui/handlers/OutputHandlers.java')
-rw-r--r-- | src/jcgp/gui/handlers/OutputHandlers.java | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/src/jcgp/gui/handlers/OutputHandlers.java b/src/jcgp/gui/handlers/OutputHandlers.java index 31d6380..7399e50 100644 --- a/src/jcgp/gui/handlers/OutputHandlers.java +++ b/src/jcgp/gui/handlers/OutputHandlers.java @@ -15,8 +15,10 @@ public final class OutputHandlers { // acquire the source, we can safely cast it to GUIOutput GUIOutput source = (GUIOutput) event.getSource(); - source.setState(GUIGeneState.HOVER); - ((GUIConnection) ((Gene) source.getOutput().getSource()).getGUIObject()).setStateRecursively(GUIGeneState.ACTIVE_HOVER); + //if (!source.isLocked()) { + source.setState(GUIGeneState.HOVER); + ((GUIConnection) ((Gene) source.getOutput().getSource()).getGUIObject()).setStateRecursively(GUIGeneState.ACTIVE_HOVER); + //} } }; @@ -26,14 +28,38 @@ public final class OutputHandlers { // acquire the source, we can safely cast it to GUIOutput GUIOutput source = (GUIOutput) event.getSource(); - source.setState(GUIGeneState.NEUTRAL); - ((GUIConnection) ((Gene) source.getOutput().getSource()).getGUIObject()).setStateRecursively(GUIGeneState.NEUTRAL); + //if (!source.isLocked()) { + source.setState(GUIGeneState.NEUTRAL); + ((GUIConnection) ((Gene) source.getOutput().getSource()).getGUIObject()).setStateRecursively(GUIGeneState.NEUTRAL); + //} + + } + }; + + private static EventHandler<MouseEvent> mouseClickHandler = new EventHandler<MouseEvent>() { + @Override + public void handle(MouseEvent event) { + // acquire the source, we can safely cast it to GUIOutput + GUIOutput source = (GUIOutput) event.getSource(); + + if (source.isLocked()) { + source.setLock(false); + ((GUIConnection) ((Gene) source.getOutput().getSource()).getGUIObject()).setLockRecursively(false); + } else { + source.setLock(true); + ((GUIConnection) ((Gene) source.getOutput().getSource()).getGUIObject()).setLockRecursively(true); + } + +// source.setState(GUIGeneState.HOVER); +// ((GUIConnection) ((Gene) source.getOutput().getSource()).getGUIObject()).setStateRecursively(GUIGeneState.ACTIVE_HOVER); + } }; public static void addHandlers(GUIOutput output) { output.addEventHandler(MouseEvent.MOUSE_ENTERED, mouseEnteredHandler); output.addEventHandler(MouseEvent.MOUSE_EXITED, mouseExitedHandler); + output.addEventHandler(MouseEvent.MOUSE_CLICKED, mouseClickHandler); } } |