Skip to content
Snippets Groups Projects
Commit 1c570288 authored by Alexander Diewald's avatar Alexander Diewald
Browse files

Merge branch '3968' into 'master'

Kernel: added keyboard movement to content anchorage controller.

See merge request !105
parents 4c54ab73 2d581794
No related branches found
No related tags found
1 merge request!105Kernel: added keyboard movement to content anchorage controller.
......@@ -3,7 +3,7 @@ ClickControllerBase.java 8e5861ed5f9318008ad0fdd5497ed320cd5bd647 GREEN
ContentAnchorageMoveControllerBase.java c18e7915ce23e124757f5b736086ecc46694800a GREEN
ControllerBase.java 0ab6cf1b36cf3618a70c1666fd8747c59e90dbc6 GREEN
DefaultDiagramController.java 0e083b89a08f63967102a384d66ebc1d64d203af GREEN
DelegatingContentAnchorageController.java 2e3b1b4e14402a3503233f816b21ef3e4aa09edc GREEN
DelegatingContentAnchorageController.java 1889628a346a2183082ffe213978f9d15a949494 GREEN
DragControllerBase.java b15ff874304f679fe494d85f57cc8cbe4d0d1d15 GREEN
DraggingUtils.java 95117e2ea4c36b6c6a31f8088bb95b484e0e6612 GREEN
LinkControllerBase.java c2232100230997f1ba7f2686a2f0626f85d223ed GREEN
......
......@@ -12,14 +12,20 @@ package org.fortiss.tooling.common.ui.javafx.lwfxef.controller.base;
import static org.fortiss.tooling.common.ui.javafx.lwfxef.EDragGesture.MOVE;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramCoordinate;
import org.fortiss.tooling.common.ui.javafx.lwfxef.DiagramViewer;
import org.fortiss.tooling.common.ui.javafx.lwfxef.EDragGesture;
import org.fortiss.tooling.common.ui.javafx.lwfxef.change.Change;
import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.IController;
import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.IDragController;
import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.IKeyPressController;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentAnchorageMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IMVCBundle;
import javafx.scene.Cursor;
import javafx.scene.Node;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
/**
* Default {@link IController} implementation for moving anchorage visuals attached to a parent
......@@ -56,6 +62,46 @@ public class DelegatingContentAnchorageController extends ControllerBase {
return super.getDragController(gesture, node, diagramLocation);
}
/** {@inheritDoc} */
@Override
public IKeyPressController getKeyPressController(Node node,
DiagramCoordinate lastMouseLocation) {
return defaultKeyPressControllerWithMove;
}
/**
* The default implementation for key press controller allowing move with cursor keys and delete
* with the delete key.
*/
private final IKeyPressController defaultKeyPressControllerWithMove =
new IKeyPressController() {
@Override
public Change keyEvent(KeyEvent event, IMVCBundle bundle, Node source,
DiagramCoordinate mouseLocation) {
DiagramViewer viewer = getViewer();
KeyCode code = event.getCode();
if(code == KeyCode.DELETE) {
return new Change() {
@Override
public void applyChange() {
delete();
}
};
}
if(code == KeyCode.A && event.isControlDown()) {
viewer.selectAll();
return null;
}
if(allowMove()) {
if(code == KeyCode.UP || code == KeyCode.DOWN || code == KeyCode.LEFT ||
code == KeyCode.RIGHT) {
return keyMove(code);
}
}
return null;
}
};
/** {@inheritDoc} */
@Override
public Cursor getCurrentCursor(Node node, DiagramCoordinate diagramLocation) {
......@@ -70,4 +116,15 @@ public class DelegatingContentAnchorageController extends ControllerBase {
protected boolean allowMove() {
return true;
}
/**
* Performs the keyboard move by returning a corresponding {@link Change}.
*
* @param code
* the arrow key code
* @return the {@link Change}, which executes the move operation.
*/
protected Change keyMove(KeyCode code) {
return null;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment