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

The following examples show how to use javafx.scene.input.KeyCode#ENTER . 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: ResultList.java    From iliasDownloaderTool with GNU General Public License v2.0 7 votes vote down vote up
private void handleKeyEvents(KeyEvent event) {
	if (event.getCode() == KeyCode.DELETE && listMode.equals(ResultListMode.IGNORE_MODE)) {
		final IliasFile file = (IliasFile) getSelectionModel().getSelectedItem();
		Settings.getInstance().toggleFileIgnored(file);
		dashboard.pdfIgnoredStateChanged(file);
		pdfIgnoredStateChanged(file);
		getSelectionModel().selectNext();
	} else if (event.getCode() == KeyCode.UP || event.getCode() == KeyCode.DOWN) {
		final IliasTreeNode selectedDirectory = ((ResultList) event.getSource())
				.getSelectionModel().getSelectedItem();
		dashboard.getCoursesTreeView().selectFile((IliasFile) selectedDirectory);
	} else if (event.getCode() == KeyCode.ENTER
			&& Settings.getInstance().getFlags().isUserLoggedIn()) {
		new Thread(new IliasPdfDownloadCaller(getSelectionModel().getSelectedItem())).start();
	}
}
 
Example 2
Source File: EcoController.java    From BetonQuest-Editor with GNU General Public License v3.0 6 votes vote down vote up
private void keyAction(KeyEvent event, Action add, Action edit, Action delete) {
	if (event.getCode() == KeyCode.DELETE) {
		if (delete != null) {
			delete.act();
		}
		event.consume();
		return;
	}
	if (event.getCode() == KeyCode.ENTER) {
		if (edit != null) {
			edit.act();
		}
		event.consume();
		return;
	}
	KeyCombination combintation = new KeyCodeCombination(KeyCode.N, KeyCombination.CONTROL_DOWN);
	if (combintation.match(event)) {
		if (add != null) {
			add.act();
		}
		event.consume();
		return;
	}
}
 
Example 3
Source File: OtherController.java    From BetonQuest-Editor with GNU General Public License v3.0 6 votes vote down vote up
private void keyAction(KeyEvent event, Action add, Action edit, Action delete) {
	if (event.getCode() == KeyCode.DELETE) {
		if (delete != null) {
			delete.act();
		}
		event.consume();
		return;
	}
	if (event.getCode() == KeyCode.ENTER) {
		if (edit != null) {
			edit.act();
		}
		event.consume();
		return;
	}
	KeyCombination combintation = new KeyCodeCombination(KeyCode.N, KeyCombination.CONTROL_DOWN);
	if (combintation.match(event)) {
		if (add != null) {
			add.act();
		}
		event.consume();
		return;
	}
}
 
Example 4
Source File: MainController.java    From BetonQuest-Editor with GNU General Public License v3.0 6 votes vote down vote up
private void keyAction(KeyEvent event, Action add, Action edit, Action delete) {
	if (event.getCode() == KeyCode.DELETE) {
		if (delete != null) {
			delete.act();
		}
		event.consume();
		return;
	}
	if (event.getCode() == KeyCode.ENTER) {
		if (edit != null) {
			edit.act();
		}
		event.consume();
		return;
	}
	KeyCombination combintation = new KeyCodeCombination(KeyCode.N, KeyCombination.CONTROL_DOWN);
	if (combintation.match(event)) {
		if (add != null) {
			add.act();
		}
		event.consume();
		return;
	}
}
 
Example 5
Source File: ConversationController.java    From BetonQuest-Editor with GNU General Public License v3.0 6 votes vote down vote up
private void keyAction(KeyEvent event, Action add, Action edit, Action delete) {
	if (event.getCode() == KeyCode.DELETE) {
		if (delete != null) {
			delete.act();
		}
		event.consume();
		return;
	}
	if (event.getCode() == KeyCode.ENTER) {
		if (edit != null) {
			edit.act();
		}
		event.consume();
		return;
	}
	KeyCombination combintation = new KeyCodeCombination(KeyCode.N, KeyCombination.CONTROL_DOWN);
	if (combintation.match(event)) {
		if (add != null) {
			add.act();
		}
		event.consume();
		return;
	}
}
 
Example 6
Source File: KeyboardExample.java    From JavaFX with MIT License 6 votes vote down vote up
private void installEventHandler(final Node keyNode) {
	// handler for enter key press / release events, other keys are
	// handled by the parent (keyboard) node handler
	final EventHandler<KeyEvent> keyEventHandler = new EventHandler<KeyEvent>() {
		public void handle(final KeyEvent keyEvent) {
			if (keyEvent.getCode() == KeyCode.ENTER) {
				setPressed(keyEvent.getEventType() == KeyEvent.KEY_PRESSED);

				keyEvent.consume();
			}
		}
	};

	keyNode.setOnKeyPressed(keyEventHandler);
	keyNode.setOnKeyReleased(keyEventHandler);
}
 
Example 7
Source File: GenericEditableTableCell.java    From JFoenix with Apache License 2.0 6 votes vote down vote up
private void createEditorNode() {
    EventHandler<KeyEvent> keyEventsHandler = t -> {
        if (t.getCode() == KeyCode.ENTER) {
            commitHelper(false);
        } else if (t.getCode() == KeyCode.ESCAPE) {
            cancelEdit();
        } else if (t.getCode() == KeyCode.TAB) {
            commitHelper(false);
            editNext(!t.isShiftDown());
        }
    };

    ChangeListener<Boolean> focusChangeListener = (observable, oldValue, newValue) -> {
        //This focus listener fires at the end of cell editing when focus is lost
        //and when enter is pressed (because that causes the text field to lose focus).
        //The problem is that if enter is pressed then cancelEdit is called before this
        //listener runs and therefore the text field has been cleaned up. If the
        //text field is null we don't commit the edit. This has the useful side effect
        //of stopping the double commit.
        if (editorNode != null && !newValue) {
            commitHelper(true);
        }
    };
    editorNode = builder.createNode(getValue(), keyEventsHandler, focusChangeListener);
}
 
Example 8
Source File: GenericEditableTreeTableCell.java    From JFoenix with Apache License 2.0 6 votes vote down vote up
private void createEditorNode() {
    EventHandler<KeyEvent> keyEventsHandler = t -> {
        if (t.getCode() == KeyCode.ENTER) {
            commitHelper(false);
        } else if (t.getCode() == KeyCode.ESCAPE) {
            cancelEdit();
        } else if (t.getCode() == KeyCode.TAB) {
            commitHelper(false);
            editNext(!t.isShiftDown());
        }
    };

    ChangeListener<Boolean> focusChangeListener = (observable, oldValue, newValue) -> {
        //This focus listener fires at the end of cell editing when focus is lost
        //and when enter is pressed (because that causes the text field to lose focus).
        //The problem is that if enter is pressed then cancelEdit is called before this
        //listener runs and therefore the text field has been cleaned up. If the
        //text field is null we don't commit the edit. This has the useful side effect
        //of stopping the double commit.
        if (editorNode != null && !newValue) {
            commitHelper(true);
        }
    };
    editorNode = builder.createNode(getValue(), keyEventsHandler, focusChangeListener);
}
 
Example 9
Source File: StringTable.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
private void handleKey(final KeyEvent event)
{
    if (event.getCode() == KeyCode.TAB)
    {
        // Edit next/prev column in same row
        final ObservableList<TableColumn<List<ObservableCellValue>, ?>> columns = getTableView().getColumns();
        final int col = columns.indexOf(getTableColumn());
        final int next = event.isShiftDown()
                       ? (col + columns.size() - 1) % columns.size()
                       : (col + 1) % columns.size();
        editCell(getIndex(), columns.get(next));
        event.consume();
    }
    else if (event.getCode() == KeyCode.ENTER)
    {
        // Consume 'enter' and move to next row. Space can be used to toggle (or mouse click)
        event.consume();
        editCell(getIndex() + 1, getTableColumn());
    }
}
 
Example 10
Source File: ConfirmDialog.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
@Override
@FxThread
protected void processKey(@NotNull final KeyEvent event) {
    if (event.getCode() == KeyCode.ENTER) {
        processClose();
    }
}
 
Example 11
Source File: Vector3fPropertyControl.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Handle of input the enter key.
 */
@FxThread
private void keyReleased(@NotNull KeyEvent event) {
    if (event.getCode() == KeyCode.ENTER) {
        changeValue();
    }
}
 
Example 12
Source File: TranslationController.java    From BetonQuest-Editor with GNU General Public License v3.0 5 votes vote down vote up
@FXML public void translationKey(KeyEvent event) {
	try {
		KeyCombination enter = new KeyCodeCombination(KeyCode.ENTER, KeyCombination.CONTROL_DOWN);
		KeyCombination backspace = new KeyCodeCombination(KeyCode.BACK_SPACE, KeyCombination.CONTROL_DOWN);
		if (enter.match(event)) {
			next();
		} else if (backspace.match(event)) {
			previous();
		}
	} catch (Exception e) {
		ExceptionController.display(e);
	}
}
 
Example 13
Source File: StringPropertyControl.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Update the value.
 */
@FxThread
private void updateValue(@NotNull KeyEvent event) {
    if (!isIgnoreListener() && event.getCode() == KeyCode.ENTER) {
        apply();
    }
}
 
Example 14
Source File: Vector3fSingleRowPropertyControl.java    From jmonkeybuilder with Apache License 2.0 5 votes vote down vote up
/**
 * Handle of input the enter key.
 */
@FxThread
private void keyReleased(@NotNull KeyEvent event) {
    if (event.getCode() == KeyCode.ENTER) {
        changeValue();
    }
}
 
Example 15
Source File: PopoverController.java    From HealthPlus with Apache License 2.0 5 votes vote down vote up
@FXML
private void selectBrand(KeyEvent e)
{
    if(e.getCode() == KeyCode.ENTER)
    {
        String brand = (String)brandList.getSelectionModel().getSelectedItem();
        text.setText(brand);

        Stage stage = (Stage) brandList.getScene().getWindow();
        stage.close();
    }
    
}
 
Example 16
Source File: MainController.java    From visual-spider with MIT License 4 votes vote down vote up
/**
 * 回车确认访问链接
 *
 * @param event {@link KeyEvent}
 */
public void urlEnter(KeyEvent event) {
    if (event.getCode() == KeyCode.ENTER) {
        toCrawl();
    }
}
 
Example 17
Source File: JavaFxRecorderHook.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
public static String keyEventGetKeyText(KeyCode keyCode) {
    if (keyCode == KeyCode.TAB) {
        return "Tab";
    }
    if (keyCode == KeyCode.CONTROL) {
        return "Ctrl";
    }
    if (keyCode == KeyCode.ALT) {
        return "Alt";
    }
    if (keyCode == KeyCode.SHIFT) {
        return "Shift";
    }
    if (keyCode == KeyCode.META) {
        return "Meta";
    }
    if (keyCode == KeyCode.SPACE) {
        return "Space";
    }
    if (keyCode == KeyCode.BACK_SPACE) {
        return "Backspace";
    }
    if (keyCode == KeyCode.HOME) {
        return "Home";
    }
    if (keyCode == KeyCode.END) {
        return "End";
    }
    if (keyCode == KeyCode.DELETE) {
        return "Delete";
    }
    if (keyCode == KeyCode.PAGE_UP) {
        return "Pageup";
    }
    if (keyCode == KeyCode.PAGE_DOWN) {
        return "Pagedown";
    }
    if (keyCode == KeyCode.UP) {
        return "Up";
    }
    if (keyCode == KeyCode.DOWN) {
        return "Down";
    }
    if (keyCode == KeyCode.LEFT) {
        return "Left";
    }
    if (keyCode == KeyCode.RIGHT) {
        return "Right";
    }
    if (keyCode == KeyCode.ENTER) {
        return "Enter";
    }
    return keyCode.getName();
}
 
Example 18
Source File: App.java    From xltsearch with Apache License 2.0 4 votes vote down vote up
@FXML
private void searchOnEnter(KeyEvent event) {
    if (event.getCode() == KeyCode.ENTER) {
        search();
    }
}
 
Example 19
Source File: JsonTabController.java    From dev-tools with Apache License 2.0 4 votes vote down vote up
@FXML
private void handleSearchBarAction(final KeyEvent event) {
    if (event.getCode() == KeyCode.ENTER) {
        handleSearchDownAction(new ActionEvent());
    }
}
 
Example 20
Source File: CreateAndSaveKMLFileController.java    From arcgis-runtime-samples-java with Apache License 2.0 4 votes vote down vote up
/**
 * Discard or commit the current sketch to a KML placemark if ESCAPE or ENTER are pressed while sketching.
 *
 * @param keyEvent the key event
 */
@FXML
private void handleKeyReleased(KeyEvent keyEvent) {
  if (keyEvent.getCode() == KeyCode.ESCAPE) {
    // clear the current sketch and start a new sketch
    startSketch();
  } else if (keyEvent.getCode() == KeyCode.ENTER && sketchEditor.isSketchValid()) {
    // project the sketched geometry to WGS84 to comply with the KML standard
    Geometry sketchGeometry = sketchEditor.getGeometry();
    Geometry projectedGeometry = GeometryEngine.project(sketchGeometry, SpatialReferences.getWgs84());

    // create a new KML placemark
    KmlGeometry kmlGeometry = new KmlGeometry(projectedGeometry, KmlAltitudeMode.CLAMP_TO_GROUND);
    KmlPlacemark currentKmlPlacemark = new KmlPlacemark(kmlGeometry);

    // update the style of the current KML placemark
    KmlStyle kmlStyle = new KmlStyle();
    currentKmlPlacemark.setStyle(kmlStyle);

    // set the selected style for the placemark
    switch (sketchGeometry.getGeometryType()) {
      case POINT:
        if (pointSymbolComboBox.getSelectionModel().getSelectedItem() != null) {
          String iconURI = pointSymbolComboBox.getSelectionModel().getSelectedItem();
          KmlIcon kmlIcon = new KmlIcon(iconURI);
          KmlIconStyle kmlIconStyle = new KmlIconStyle(kmlIcon, 1);
          kmlStyle.setIconStyle(kmlIconStyle);
        }
        break;
      case POLYLINE:
        Color polylineColor = colorPicker.getValue();
        if (polylineColor != null) {
          KmlLineStyle kmlLineStyle = new KmlLineStyle(ColorUtil.colorToArgb(polylineColor), 8);
          kmlStyle.setLineStyle(kmlLineStyle);
        }
        break;
      case POLYGON:
        Color polygonColor = colorPicker.getValue();
        if (polygonColor != null) {
          KmlPolygonStyle kmlPolygonStyle = new KmlPolygonStyle(ColorUtil.colorToArgb(polygonColor));
          kmlPolygonStyle.setFilled(true);
          kmlPolygonStyle.setOutlined(false);
          kmlStyle.setPolygonStyle(kmlPolygonStyle);
        }
        break;
    }

    // add the placemark to the kml document
    kmlDocument.getChildNodes().add(currentKmlPlacemark);

    // start a new sketch
    startSketch();
  }
}