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

The following examples show how to use javafx.scene.input.KeyCode#DOWN . 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: TestTarget.java    From ShootOFF with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testDownArrowKeyMoveTarget() {
	double oldX = pepperPopper.getPosition().getX();
	double oldY = pepperPopper.getPosition().getY();

	KeyEvent downArrowEvent = new KeyEvent(null, pepperPopper.getTargetGroup(), KeyEvent.KEY_PRESSED, "down",
			"down", KeyCode.DOWN, false, false, false, false);
	Event.fireEvent(pepperPopper.getTargetGroup(), downArrowEvent);

	assertEquals(oldX, pepperPopper.getPosition().getX(), .001);
	assertEquals(oldY + TargetView.MOVEMENT_DELTA, pepperPopper.getPosition().getY(), .001);
}
 
Example 3
Source File: TestTarget.java    From ShootOFF with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testDownArrowKeyResizeTarget() {
	double oldWidth = pepperPopper.getDimension().getWidth();
	double oldHeight = pepperPopper.getDimension().getHeight();

	KeyEvent downArrowEvent = new KeyEvent(null, pepperPopper.getTargetGroup(), KeyEvent.KEY_PRESSED, "down",
			"down", KeyCode.DOWN, true, false, false, false);
	Event.fireEvent(pepperPopper.getTargetGroup(), downArrowEvent);

	assertEquals(oldWidth, pepperPopper.getDimension().getWidth(), .001);
	assertEquals(oldHeight - TargetView.SCALE_DELTA, pepperPopper.getDimension().getHeight(), .001);
}
 
Example 4
Source File: TestTarget.java    From ShootOFF with GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testDownArrowKeyProportionalResizeTarget() {
	double oldWidth = pepperPopper.getDimension().getWidth();
	double oldHeight = pepperPopper.getDimension().getHeight();

	KeyEvent downArrowEvent = new KeyEvent(null, pepperPopper.getTargetGroup(), KeyEvent.KEY_PRESSED, "down",
			"down", KeyCode.DOWN, true, true, false, false);
	Event.fireEvent(pepperPopper.getTargetGroup(), downArrowEvent);

	assertEquals(oldWidth - (TargetView.SCALE_DELTA * (oldWidth / oldHeight)), pepperPopper.getDimension().getWidth(), .001);
	assertEquals(oldHeight - TargetView.SCALE_DELTA, pepperPopper.getDimension().getHeight(), .001);
}
 
Example 5
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 6
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 7
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();
}