|
@@ -1,5 +1,9 @@
|
|
|
package de.tu_darmstadt.informatik.tk.scopviz.ui.handlers;
|
|
|
|
|
|
+import de.tu_darmstadt.informatik.tk.scopviz.debug.Debug;
|
|
|
+import de.tu_darmstadt.informatik.tk.scopviz.main.CreationMode;
|
|
|
+import de.tu_darmstadt.informatik.tk.scopviz.main.Layer;
|
|
|
+import de.tu_darmstadt.informatik.tk.scopviz.main.Main;
|
|
|
import javafx.event.EventHandler;
|
|
|
import javafx.scene.input.KeyCode;
|
|
|
import javafx.scene.input.KeyCodeCombination;
|
|
@@ -18,8 +22,8 @@ import javafx.stage.Stage;
|
|
|
public final class KeyboardShortcuts {
|
|
|
|
|
|
// example of keycombinations
|
|
|
- final static KeyCombination rCtrl = new KeyCodeCombination(KeyCode.M, KeyCombination.CONTROL_DOWN);
|
|
|
- final static KeyCombination rCtrlShift = new KeyCodeCombination(KeyCode.R, KeyCombination.CONTROL_DOWN,
|
|
|
+ final static KeyCombination mShift = new KeyCodeCombination(KeyCode.M, KeyCombination.SHIFT_DOWN);
|
|
|
+ final static KeyCombination rAltShift = new KeyCodeCombination(KeyCode.R, KeyCombination.ALT_DOWN,
|
|
|
KeyCombination.SHIFT_DOWN);
|
|
|
|
|
|
/**
|
|
@@ -36,7 +40,8 @@ public final class KeyboardShortcuts {
|
|
|
*/
|
|
|
public static void initialize(Stage primaryStage) {
|
|
|
|
|
|
- primaryStage.addEventFilter(KeyEvent.KEY_RELEASED, buttonsPressed);
|
|
|
+ primaryStage.addEventFilter(KeyEvent.KEY_PRESSED, buttonsPressed);
|
|
|
+ primaryStage.addEventFilter(KeyEvent.KEY_RELEASED, buttonsReleased);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -47,13 +52,45 @@ public final class KeyboardShortcuts {
|
|
|
|
|
|
@Override
|
|
|
public void handle(KeyEvent event) {
|
|
|
+
|
|
|
+ if(event.getCode() == KeyCode.CONTROL){
|
|
|
+
|
|
|
+ //for functionality of holding down ctrl for creating mapping edges
|
|
|
+ if(Main.getInstance().getGraphManager().getGraph().getAttribute("layer") == Layer.MAPPING){
|
|
|
+ Main.getInstance().setCreationMode(CreationMode.CREATE_DIRECTED_EDGE);
|
|
|
+ Debug.out("Ctrl pressed");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
- if (rCtrl.match(event)) {
|
|
|
- System.out.println("Ctrl+M pressed");
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * A general Handler for any Button releases
|
|
|
+ */
|
|
|
+ private static EventHandler<KeyEvent> buttonsReleased = new EventHandler<KeyEvent>() {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void handle(KeyEvent event) {
|
|
|
+
|
|
|
+ if (mShift.match(event)) {
|
|
|
+ Debug.out("M+Shift released");
|
|
|
}
|
|
|
|
|
|
- else if (rCtrlShift.match(event)) {
|
|
|
- System.out.println("Ctrl+Shift+R pressed");
|
|
|
+ else if (rAltShift.match(event)) {
|
|
|
+ Debug.out("Alt+Shift+R released");
|
|
|
+ }
|
|
|
+
|
|
|
+ else if(event.getCode() == KeyCode.CONTROL){
|
|
|
+
|
|
|
+ //for functionality of holding down ctrl for creating mapping edges
|
|
|
+ if(Main.getInstance().getGraphManager().getGraph().getAttribute("layer") == Layer.MAPPING){
|
|
|
+ Main.getInstance().setCreationMode(CreationMode.CREATE_NONE);
|
|
|
+ Main.getInstance().getGraphManager().deselectEdgeCreationNodes();
|
|
|
+ Debug.out("Ctrl released");
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|