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

The following examples show how to use javafx.scene.input.KeyCode#DELETE . 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: DeleteSelectedOnTypeHandler.java    From gef with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Returns <code>true</code> if the given {@link KeyEvent} is a "delete"
 * event, i.e. the {@link KeyEvent#getCode()} is {@link KeyCode#DELETE} and
 * no drag policy is currently running. Otherwise returns <code>false</code>
 * .
 *
 * @param event
 *            The {@link KeyEvent} in question.
 * @return <code>true</code> if the given {@link KeyEvent} should trigger
 *         content deletion, otherwise <code>false</code>.
 */
protected boolean isDelete(KeyEvent event) {
	// only delete on <DELETE> key
	if (event.getCode() != KeyCode.DELETE) {
		return false;
	}

	// prevent deletion when other drag policies are running
	ClickDragGesture tool = getHost().getRoot().getViewer().getDomain()
			.getAdapter(ClickDragGesture.class);
	if (tool != null && getHost().getRoot().getViewer().getDomain()
			.isExecutionTransactionOpen(tool)) {
		return false;
	}

	return true;
}
 
Example 3
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 4
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 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: 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 7
Source File: MessageDisplay.java    From xltsearch with Apache License 2.0 5 votes vote down vote up
@FXML
private void deleteMessage(KeyEvent event) {
    if (event.getCode() == KeyCode.DELETE) {
        Message msg = table.getSelectionModel().getSelectedItem();
        if (msg != null) {
            MessageLogger.messagesProperty().get().remove(msg);
        }
    }
}
 
Example 8
Source File: SortedChoiceController.java    From BetonQuest-Editor with GNU General Public License v3.0 5 votes vote down vote up
@FXML private void key(KeyEvent event) {
	try {
		if (event.getCode() == KeyCode.ESCAPE) {
			stage.close();
			refresher.refresh();
			return;
		}
		if (event.getCode() == KeyCode.DELETE && list.isFocused()) {
			delete();
			return;
		}
		W item = list.getSelectionModel().getSelectedItem();
		if (item != null) {
			int index = list.getItems().indexOf(item);
			if (moveUp.match(event)) {
				if (index > 0) {
					list.getItems().set(index, list.getItems().get(index - 1));
					list.getItems().set(index - 1, item);
				}
				return;
			} else if (moveDown.match(event)) {
				if (index + 1 < list.getItems().size()) {
					list.getItems().set(index, list.getItems().get(index + 1));
					list.getItems().set(index + 1, item);
				}
				return;
			}
			list.getSelectionModel().select(item);
		}
		if (item instanceof ConditionWrapper && invert.match(event)) {
			ConditionListCell.invert((ConditionWrapper) item);
		}
	} catch (Exception e) {
		ExceptionController.display(e);
	}
}
 
Example 9
Source File: AutoCompleteComboBoxListener.java    From Path-of-Leveling with MIT License 4 votes vote down vote up
@Override
public void handle(KeyEvent event) {

    if(event.getCode() == KeyCode.UP) {
        caretPos = -1;
        moveCaret(comboBox.getEditor().getText().length());
        return;
    } else if(event.getCode() == KeyCode.DOWN) {
        if(!comboBox.isShowing()) {
            comboBox.show();
        }
        caretPos = -1;
        moveCaret(comboBox.getEditor().getText().length());
        return;
    } else if(event.getCode() == KeyCode.BACK_SPACE) {
        moveCaretToPos = true;
        caretPos = comboBox.getEditor().getCaretPosition();
    } else if(event.getCode() == KeyCode.DELETE) {
        moveCaretToPos = true;
        caretPos = comboBox.getEditor().getCaretPosition();
    }

    if(event.getCharacter().matches("[a-z]"))
        comboBox.setValue(
                (T) String.valueOf(comboBox.getValue()).toUpperCase()
        );

    if (event.getCode() == KeyCode.RIGHT || event.getCode() == KeyCode.LEFT
            || event.isControlDown() || event.getCode() == KeyCode.HOME
            || event.getCode() == KeyCode.END || event.getCode() == KeyCode.TAB) {
        return;
    }

    //if(comboBox.getItems().isEmpty()) comboBox.getItems().addAll(data);
    
   ObservableList<T> list = FXCollections.observableArrayList();
    for (T aData : data) {
        if(sc.toString(aData).toLowerCase().contains
                    (AutoCompleteComboBoxListener.this.comboBox
                    .getEditor().getText().toLowerCase())
                ){
            list.add(aData);
        }
        /*
        if (String.valueOf(aData).toLowerCase().startsWith(
                AutoCompleteComboBoxListener.this.comboBox
                        .getEditor().getText().toLowerCase())) {
            list.add(aData);
        }*/
    }
    String t = comboBox.getEditor().getText();
    comboBox.getItems().clear();
    comboBox.getItems().addAll(list);
    comboBox.getEditor().setText(t);
    if(!moveCaretToPos) {
        caretPos = -1;
    }
    moveCaret(t.length());
    if(!list.isEmpty()) {
        comboBox.show();
    }
}
 
Example 10
Source File: OSFXUtils.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 11
Source File: WSRecorder.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
private boolean needManualRecording(KeyCode keyCode) {
    return keyCode == KeyCode.BACK_SPACE || keyCode == KeyCode.DELETE || keyCode == KeyCode.ESCAPE || keyCode == KeyCode.SPACE;
}
 
Example 12
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 13
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);
}
 
Example 14
Source File: ResourceTree.java    From jmonkeybuilder with Apache License 2.0 4 votes vote down vote up
/**
 * Handle hotkeys.
 */
@FxThread
private void processKey(@NotNull KeyEvent event) {

    if (isReadOnly()) {
        return;
    }

    var editorConfig = EditorConfig.getInstance();
    var currentAsset = editorConfig.getCurrentAsset();
    if (currentAsset == null) {
        return;
    }

    updateSelectedElements();

    var selectedElements = getSelectedElements();
    if (selectedElements.isEmpty()) {
        return;
    }

    var firstElement = selectedElements.first();
    if (firstElement instanceof LoadingResourceElement) {
        return;
    }

    boolean onlyFiles = true;
    boolean onlyFolders = true;
    boolean selectedAsset = false;

    for (var element : selectedElements.array()) {

        if (element == null) {
            break;
        }

        if (element instanceof FileResourceElement) {
            onlyFolders = false;
        } else if (element instanceof FolderResourceElement) {
            onlyFiles = false;
        }

        if (Objects.equals(currentAsset, element.getFile())) {
            selectedAsset = true;
        }
    }

    var actionTester = getActionTester();
    var keyCode = event.getCode();
    var controlDown = event.isControlDown();

    if (!currentAsset.equals(firstElement.getFile())) {

        if (controlDown) {

            if (keyCode == KeyCode.C && actionTester.test(CopyFileAction.class) &&
                    !selectedAsset && (onlyFiles || selectedElements.size() == 1)) {

                CopyFileAction.applyFor(selectedElements);

            } else if (keyCode == KeyCode.X && actionTester.test(CutFileAction.class) &&
                    !selectedAsset && (onlyFiles || selectedElements.size() == 1)) {

                CutFileAction.applyFor(selectedElements);
            }

        } else if (keyCode == KeyCode.DELETE && actionTester.test(DeleteFileAction.class) &&
                !selectedAsset && (onlyFiles || selectedElements.size() == 1)) {

            DeleteFileAction.applyFor(selectedElements);
        }
    }

    if (controlDown && keyCode == KeyCode.V && hasFileInClipboard() &&
            actionTester.test(PasteFileAction.class)) {

        PasteFileAction.applyFor(firstElement);
    }
}