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

The following examples show how to use javafx.scene.input.KeyCode#HOME . 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: 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 2
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 3
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();
}