本文整理汇总了Java中javafx.scene.input.KeyCode.BACK_SPACE属性的典型用法代码示例。如果您正苦于以下问题:Java KeyCode.BACK_SPACE属性的具体用法?Java KeyCode.BACK_SPACE怎么用?Java KeyCode.BACK_SPACE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javafx.scene.input.KeyCode
的用法示例。
在下文中一共展示了KeyCode.BACK_SPACE属性的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: thumbKeyPressed
@FXML
void thumbKeyPressed(KeyEvent e) {
if (e.getCode() == KeyCode.BACK_SPACE || e.getCode() == KeyCode.DELETE) {
gradientPicker.removeStop(this);
// Called when removing a gradient stop :
// - update gradient preview accordingly
// - update model
final PaintPickerController paintPicker
= gradientPicker.getPaintPickerController();
final Mode mode = paintPicker.getMode();
final Paint value = gradientPicker.getValue(mode);
gradientPicker.updatePreview(value);
// Update model
paintPicker.setPaintProperty(value);
e.consume();
}
}
示例2: handleOnKeyPressed
private void handleOnKeyPressed(KeyEvent keyEvent) {
KeyCode code = keyEvent.getCode();
if (!keyEvent.isMetaDown()) {
String filterValue = filter.get();
//log.debug("Handling KeyCode = " + code);
if (code.isLetterKey() || code.isDigitKey() || code == KeyCode.MINUS) {
filterValue += keyEvent.getText();
} else if ((code == KeyCode.BACK_SPACE) && (filterValue.length() > 0)) {
filterValue = filterValue.substring(0, filterValue.length() - 1);
} else if (code == KeyCode.ESCAPE) {
filterValue = EMPTY;
} else if ((code == KeyCode.DOWN) || (code == KeyCode.UP)) {
comboBox.show();
}
filter.set(filterValue);
comboBox.getTooltip().textProperty().set(filterValue);
}
}
示例3: handle
@Override
public void handle(KeyEvent event) {
TextField editor = comboBox.getEditor();
String text = editor.getText();
if (event.getCode() == KeyCode.RIGHT
|| event.getCode() == KeyCode.LEFT
|| event.isControlDown()
|| event.getCode() == KeyCode.HOME
|| event.getCode() == KeyCode.END
|| event.getCode() == KeyCode.TAB) {
return;
}
else if(event.getCode() == KeyCode.UP) {
caretPos = -1;
moveCaret(text.length());
return;
}
else if(event.getCode() == KeyCode.DOWN) {
if(!comboBox.isShowing()) {
comboBox.show();
}
caretPos = -1;
moveCaret(text.length());
return;
}
else if(event.getCode() == KeyCode.BACK_SPACE) {
moveCaretToPos = true;
caretPos = editor.getCaretPosition();
}
else if(event.getCode() == KeyCode.DELETE) {
moveCaretToPos = true;
caretPos = editor.getCaretPosition();
}
String upperCaseText = text.toUpperCase();
ObservableList<T> list = FXCollections.observableArrayList(data.stream()
.filter(s -> transform.apply(s).toUpperCase().startsWith(upperCaseText))
.collect(Collectors.toList()));
comboBox.setItems(list);
if (event.getCode() == KeyCode.ENTER
|| event.getCode() == KeyCode.ESCAPE) {
if (!list.isEmpty()) {
comboBox.getEditor().setText(transform.apply(list.get(0)));
comboBox.getSelectionModel().select(0);
comboBox.hide();
}
else {
comboBox.getEditor().setText(text);
}
}
else {
comboBox.getEditor().setText(text);
if(!moveCaretToPos) {
caretPos = -1;
}
moveCaret(text.length());
if(!list.isEmpty()) {
comboBox.show();
}
}
}
示例4: keyEventGetKeyText
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();
}
示例5: needManualRecording
private boolean needManualRecording(KeyCode keyCode) {
return keyCode == KeyCode.BACK_SPACE || keyCode == KeyCode.DELETE || keyCode == KeyCode.ESCAPE || keyCode == KeyCode.SPACE;
}
示例6: keyEventGetKeyText
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();
}
示例7: asKeyCombinationMain
/**
* Converts the textual representation of a key into a JavaFX {@link KeyCode}
* @param name Key string
* @return JavaFX <code>KeyCode</code> object
*/
private static KeyCode asKeyCombinationMain(String name) {
if(name == null || name.isEmpty())
throw new IllegalArgumentException("Key definition is null or empty");
name = name.toUpperCase();
if(name.length() == 1) {
if(Character.isAlphabetic(name.charAt(0)))
return KeyCode.valueOf(name);
if(Character.isDigit(name.charAt(0)))
return KeyCode.valueOf("DIGIT" + name);
switch(name.charAt(0)) {
case '&':
return KeyCode.AMPERSAND;
case '*':
return KeyCode.ASTERISK;
case '^':
return KeyCode.CIRCUMFLEX;
case '!':
return KeyCode.EXCLAMATION_MARK;
case '\\':
return KeyCode.BACK_SLASH;
case '+':
return KeyCode.PLUS;
}
throw new IllegalArgumentException("Unknown or unsupported key: " + name);
}
switch(name) {
case "BACKSPACE":
return KeyCode.BACK_SPACE;
case "SPACE":
case "SPACEBAR":
return KeyCode.SPACE;
default:
return KeyCode.valueOf(name);
}
}
示例8: isBackSpace
protected boolean isBackSpace(KeyEvent event) {
return event.getCode() == KeyCode.BACK_SPACE;
}
示例9: onKeyPressed
private void onKeyPressed(KeyEvent event) {
if (event.getCode() == KeyCode.BACK_SPACE) {
eventBus.post(MenuActionEvent.DELETE_SELECTION);
}
}