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

The following examples show how to use javafx.scene.input.KeyCode#T . 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: RTImagePlot.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
/** onKeyPressed */
private void keyPressed(final KeyEvent event)
{
    if (! handle_keys || axisLimitsField.isVisible())
        return;
    if (event.getCode() == KeyCode.Z)
        plot.getUndoableActionManager().undoLast();
    else if (event.getCode() == KeyCode.Y)
        plot.getUndoableActionManager().redoLast();
    else if (event.getCode() == KeyCode.O)
        showConfigurationDialog();
    else if (event.getCode() == KeyCode.C)
        toolbar.toggleCrosshair();
    else if (event.getCode() == KeyCode.T)
        showToolbar(! isToolbarVisible());
    else if (event.isControlDown())
        toolbar.selectMouseMode(MouseMode.ZOOM_IN);
    else if (event.isAltDown())
        toolbar.selectMouseMode(MouseMode.ZOOM_OUT);
    else if (event.isShiftDown())
        toolbar.selectMouseMode(MouseMode.PAN);
    else
        toolbar.selectMouseMode(MouseMode.NONE);
    event.consume();
}
 
Example 2
Source File: RTPlot.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
/** onKeyPressed */
private void keyPressed(final KeyEvent event)
{
    if (! handle_keys || axisLimitsField.isVisible() )
        return;
    if (event.getCode() == KeyCode.Z)
        plot.getUndoableActionManager().undoLast();
    else if (event.getCode() == KeyCode.Y)
        plot.getUndoableActionManager().redoLast();
    else if (event.getCode() == KeyCode.O)
        showConfigurationDialog();
    else if (event.getCode() == KeyCode.T)
        showToolbar(! isToolbarVisible());
    else if (event.getCode() == KeyCode.C)
        toolbar.toggleCrosshair();
    else if (event.getCode() == KeyCode.L)
        plot.showLegend(! plot.isLegendVisible());
    else if (event.getCode() == KeyCode.S)
        plot.stagger(true);
    else if (event.getCode() == KeyCode.A)
        plot.enableAutoScale();
    else if (event.isControlDown())
        toolbar.selectMouseMode(MouseMode.ZOOM_IN);
    else if (event.isAltDown())
        toolbar.selectMouseMode(MouseMode.ZOOM_OUT);
    else if (event.isShiftDown())
        toolbar.selectMouseMode(MouseMode.PAN);
    else
        toolbar.selectMouseMode(MouseMode.NONE);
    event.consume();
}
 
Example 3
Source File: StringTable.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
/** Handle key pressed on the table
 *
 *  <p>Ignores keystrokes while editing a cell.
 *
 *  @param event Key pressed
 */
private void handleKey(final KeyEvent event)
{
    if (! editing)
    {
        // Toggle toolbar on Ctrl/Command T
        if (event.getCode() == KeyCode.T  &&  event.isShortcutDown())
        {
            showToolbar(! isToolbarVisible());
            event.consume();
            return;
        }

        // Switch to edit mode on keypress
        if  (event.getCode().isLetterKey() || event.getCode().isDigitKey())
        {
            @SuppressWarnings("unchecked")
            final TablePosition<List<ObservableCellValue>, ?> pos = table.getFocusModel().getFocusedCell();
            table.edit(pos.getRow(), pos.getTableColumn());

            // TODO If the cell had been edited before, i.e. the editor already exists,
            // that editor will be shown and it will receive the key.
            // But if the editor needed to be created for a new cell,
            // it won't receive the key?!
            // Attempts to re-send the event via a delayed
            //   Event.fireEvent(table, event.copyFor(event.getSource(), table));
            // failed to have any effect.
        }
    }
}
 
Example 4
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();
    }
  });
}