Java Code Examples for javafx.scene.input.KeyCode#R

The following examples show how to use javafx.scene.input.KeyCode#R . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FeatureTableFX.java    From mzmine3 with GNU General Public License v2.0 4 votes vote down vote up
private void setTableEditable(boolean state) {
  this.setEditable(true);// when character or numbers pressed it will start edit in editable
  // fields

  // enable copy on selection
  final KeyCodeCombination keyCodeCopy =
      new KeyCodeCombination(KeyCode.C, KeyCombination.CONTROL_ANY);
  final KeyCodeCombination keyCodeRandomComment =
      new KeyCodeCombination(KeyCode.R, KeyCombination.CONTROL_ANY);
  final KeyCodeCombination keyCodeRandomMZ =
      new KeyCodeCombination(KeyCode.T, KeyCombination.CONTROL_ANY);

  this.setOnKeyPressed(event -> {
    if (keyCodeCopy.match(event)) {
      copySelectionToClipboard(this, true);
    }
    if (keyCodeRandomComment.match(event)) {
      this.getSelectionModel().getSelectedItem().getValue().set(CommentType.class,
          ("Random" + rand.nextInt(100)));
      this.getSelectionModel().getSelectedItem().getValue().getFeatures().values().stream()
          .forEach(f -> f.set(CommentType.class, ("Random" + rand.nextInt(100))));
    }
    if (keyCodeRandomMZ.match(event)) {
      this.getSelectionModel().getSelectedItem().getValue().set(MZType.class,
          (rand.nextDouble() * 200d));
      this.getSelectionModel().getSelectedItem().getValue().getFeatures().values().stream()
          .forEach(f -> f.set(MZType.class, (rand.nextDouble() * 200d)));
    }

    if (event.getCode().isLetterKey() || event.getCode().isDigitKey()) {
      editFocusedCell();
    } else if (event.getCode() == KeyCode.RIGHT || event.getCode() == KeyCode.TAB) {
      this.getSelectionModel().selectNext();
      event.consume();
    } else if (event.getCode() == KeyCode.LEFT) {
      this.getSelectionModel().selectPrevious();
      // work around due to
      // TableView.getSelectionModel().selectPrevious() due to a bug
      // stopping it from working on
      // the first column in the last row of the table
      // selectPrevious();
      event.consume();
    }
  });
}
 
Example 2
Source File: AbstractSceneFileEditor.java    From jmonkeybuilder with Apache License 2.0 4 votes vote down vote up
@Override
@FxThread
protected boolean handleKeyActionImpl(@NotNull final KeyCode keyCode, final boolean isPressed,
                                      final boolean isControlDown, final boolean isShiftDown,
                                      final boolean isButtonMiddleDown) {

    final MA editor3DPart = getEditor3DPart();
    if (editor3DPart.isCameraMoving()) {
        return false;
    }

    if (isPressed && isControlDown && keyCode == KeyCode.Z) {
        undo();
        return true;
    } else if (isPressed && isControlDown && keyCode == KeyCode.Y) {
        redo();
        return true;
    } else if (isPressed && keyCode == KeyCode.G && !isControlDown && !isButtonMiddleDown) {
        final ToggleButton moveToolButton = getMoveToolButton();
        moveToolButton.setSelected(true);
        return true;
    } else if (isPressed && keyCode == KeyCode.R && !isControlDown && !isButtonMiddleDown) {
        final ToggleButton rotationToolButton = getRotationToolButton();
        rotationToolButton.setSelected(true);
        return true;
    } else if (isPressed && keyCode == KeyCode.S && !isControlDown && !isButtonMiddleDown) {
        final ToggleButton scaleToolButton = getScaleToolButton();
        scaleToolButton.setSelected(true);
        return true;
    } else if (isPressed && keyCode == KeyCode.DELETE) {

        final RemoveElementsAction removeAction = findTreeAction(RemoveElementsAction.class);

        if (removeAction == null) {
            return false;
        }

        removeAction.process();
        return true;

    } else if (isPressed && isControlDown && keyCode == KeyCode.C) {
        //TODO
    } else if (isPressed && isControlDown && keyCode == KeyCode.V) {
        //TODO
    }

    return super.handleKeyActionImpl(keyCode, isPressed, isControlDown, isShiftDown, isButtonMiddleDown);
}