use of javafx.scene.input.KeyEvent in project jphp by jphp-compiler.
the class UXKeyboardManager method onPress.
@Signature
public void onPress(KeyCombination keys, Invoker handler, String group, Environment env) {
EventHandler<KeyEvent> onPress = getWrappedObject().getOnPress(keys);
if (onPress == null) {
onPress = new ScriptEventHandler<>(env);
getWrappedObject().setOnPress(keys, onPress);
}
ScriptEventHandler eventHandler = (ScriptEventHandler) onPress;
eventHandler.set(handler, group);
}
use of javafx.scene.input.KeyEvent in project jphp by jphp-compiler.
the class KeyboardManager method trigger.
protected void trigger(KeyCombination keyCombination, KeyCode code, Map<KeyCombination, EventHandler<KeyEvent>> handlers) {
EventHandler<KeyEvent> eventHandler = handlers.get(keyCombination);
if (eventHandler != null) {
KeyEvent event = new KeyEvent(window, window, KeyEvent.KEY_PRESSED, null, null, code, shiftDown, controlDown, altDown, false);
eventHandler.handle(event);
}
}
use of javafx.scene.input.KeyEvent in project Malai by arnobl.
the class JfxFSM method removeKeyEvent.
/**
* Removes the given KeyPress event from the events 'still in process' list.
* @param key The key code of the event to remove.
*/
private void removeKeyEvent(final KeyCode key) {
if (eventsToProcess == null) {
return;
}
synchronized (eventsToProcess) {
boolean removed = false;
Event event;
for (int i = 0, size = eventsToProcess.size(); i < size && !removed; i++) {
event = eventsToProcess.get(i);
if (event instanceof KeyEvent && ((KeyEvent) event).getCode() == key) {
removed = true;
eventsToProcess.remove(i);
}
}
}
}
use of javafx.scene.input.KeyEvent in project jgnash by ccavanaugh.
the class ReportViewerDialogController method initialize.
@FXML
private void initialize() {
busyPane = new BusyPane();
stackPane.getChildren().add(busyPane);
saveButton.disableProperty().bind(report.isNull());
reportFormatButton.disableProperty().bind(report.isNull());
fontSizeSpinner.disableProperty().bind(report.isNull());
firstButton.disableProperty().bind(report.isNull().or(pageCount.isEqualTo(0)).or(pageIndex.isEqualTo(0)));
previousButton.disableProperty().bind(report.isNull().or(pageCount.isEqualTo(0)).or(pageIndex.isEqualTo(0)));
nextButton.disableProperty().bind(report.isNull().or(pageCount.isEqualTo(0)).or(pageIndex.isEqualTo(pageCount.subtract(1))));
lastButton.disableProperty().bind(report.isNull().or(pageCount.isEqualTo(0)).or(pageIndex.isEqualTo(pageCount.subtract(1))));
fitPageButton.disableProperty().bind(report.isNull());
fitHeightButton.disableProperty().bind(report.isNull());
fitWidthButton.disableProperty().bind(report.isNull());
zoomComboBox.disableProperty().bind(report.isNull());
zoomInButton.disableProperty().bind(report.isNull().or(zoomProperty.greaterThanOrEqualTo(DEFAULT_ZOOMS[DEFAULT_ZOOMS.length - 1] / 100)));
zoomOutButton.disableProperty().bind(report.isNull().or(zoomProperty.lessThanOrEqualTo(DEFAULT_ZOOMS[0] / 100)));
fitPageButton.setSelected(true);
firstButton.prefHeightProperty().bind(saveButton.heightProperty());
previousButton.prefHeightProperty().bind(saveButton.heightProperty());
nextButton.prefHeightProperty().bind(saveButton.heightProperty());
lastButton.prefHeightProperty().bind(saveButton.heightProperty());
zoomInButton.prefHeightProperty().bind(saveButton.heightProperty());
zoomOutButton.prefHeightProperty().bind(saveButton.heightProperty());
fitHeightButton.prefHeightProperty().bind(saveButton.heightProperty());
fitWidthButton.prefHeightProperty().bind(saveButton.heightProperty());
fitPageButton.prefHeightProperty().bind(saveButton.heightProperty());
fontSizeSpinner.setValueFactory(new SpinnerValueFactory.DoubleSpinnerValueFactory(5, 15, 7));
// act when the report property has been set or changed
report.addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
fontSizeSpinner.valueFactoryProperty().get().setValue((double) newValue.getBaseFontSize());
}
});
reportControllerPaneProperty.addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
reportControllerPane.getChildren().addAll(newValue);
}
});
fontSizeSpinner.valueProperty().addListener((observable, oldValue, newValue) -> {
report.get().setBaseFontSize(newValue.floatValue());
if (reportController != null) {
reportController.refreshReport();
}
});
pagePane.setSpacing(PAGE_BORDER);
pagePane.setPadding(new Insets(PAGE_BORDER));
pagePane.setAlignment(Pos.CENTER);
scrollPane.viewportBoundsProperty().addListener((observable, oldValue, newValue) -> {
if (fitWidthButton.isSelected()) {
handleFitPageWidthAction();
}
scrollPane.setFitToWidth(pagePane.prefWidth(-1) < newValue.getWidth());
scrollPane.setFitToHeight(pagePane.prefHeight(-1) < newValue.getHeight());
});
scrollPane.vvalueProperty().addListener((ObservableValue<? extends Number> observable, Number oldValue, Number newValue) -> {
final double interval = 1d / pageCount.get();
double low = pageIndex.get() * interval;
double hi = low + interval;
int newPageIndex = pageIndex.get();
if (hi < newValue.doubleValue() && pageIndex.get() < pageCount.get()) {
while (hi < newValue.doubleValue()) {
newPageIndex++;
hi += interval;
}
// increase the page index to match the scroll position
setPageIndex(newPageIndex);
} else if (low > newValue.doubleValue() && pageIndex.get() > 0) {
while (low > newValue.doubleValue()) {
newPageIndex--;
low -= interval;
}
// decrease the page index to match the scroll position
setPageIndex(newPageIndex);
}
});
for (int zoom : DEFAULT_ZOOMS) {
zoomComboBox.getItems().add(zoom + "%");
}
zoomComboBox.getSelectionModel().select(DEFAULT_ZOOM_INDEX);
zoomComboBox.addEventHandler(KeyEvent.KEY_PRESSED, (KeyEvent e) -> {
if (e.getCode() == KeyCode.ENTER) {
handleZoomChangedAction();
}
});
setZoomRatio(1);
// this ensures the report is properly closed when the dialog is closed
parent.addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
parent.get().getWindow().setOnCloseRequest(event -> {
try {
report.get().close();
} catch (IOException e) {
e.printStackTrace();
}
});
}
});
}
use of javafx.scene.input.KeyEvent in project Minesweeper3D by SethDamiani.
the class Main method createCube.
private void createCube(Group cubeGroup, Group gX, Group gY, Scene scene, Stage stage) {
cubeGroup.setTranslateZ(-200);
sideB.setTranslateX(200);
sideB.setTranslateZ(200);
sideB.setRotationAxis(new Point3D(0, 1, 0));
sideB.setRotate(90);
sideC.setTranslateZ(200);
sideC.setTranslateX(-200);
sideC.setRotationAxis(new Point3D(0, 1, 0));
sideC.setRotate(90);
sideD.setTranslateZ(400);
sideE.setRotationAxis(new Point3D(1, 0, 0));
sideE.setRotate(90);
sideE.setTranslateY(200);
sideE.setTranslateZ(200);
sideF.setRotationAxis(new Point3D(1, 0, 0));
sideF.setRotate(90);
sideF.setTranslateY(-200);
sideF.setTranslateZ(200);
RotateTransition rightRotate = new RotateTransition(Duration.millis(10000), gY);
rightRotate.setAxis(Rotate.Y_AXIS);
rightRotate.setByAngle(-1000);
rightRotate.setInterpolator(Interpolator.LINEAR);
RotateTransition leftRotate = new RotateTransition(Duration.millis(10000), gY);
leftRotate.setAxis(Rotate.Y_AXIS);
leftRotate.setByAngle(1000);
leftRotate.setInterpolator(Interpolator.LINEAR);
RotateTransition upRotate = new RotateTransition(Duration.millis(10000), gX);
upRotate.setAxis(Rotate.X_AXIS);
upRotate.setByAngle(-1000);
upRotate.setInterpolator(Interpolator.LINEAR);
RotateTransition downRotate = new RotateTransition(Duration.millis(10000), gX);
downRotate.setAxis(Rotate.X_AXIS);
downRotate.setByAngle(1000);
downRotate.setInterpolator(Interpolator.LINEAR);
EventHandler<KeyEvent> KeyPressHandler = event -> {
if (event.getCode() == KeyCode.ESCAPE) {
timeTask.pause();
stage.setScene(confirmExit);
} else if (event.getCode() == KeyCode.D || event.getCode() == KeyCode.RIGHT)
rightRotate.play();
else if (event.getCode() == KeyCode.A || event.getCode() == KeyCode.LEFT)
leftRotate.play();
else if (event.getCode() == KeyCode.W || event.getCode() == KeyCode.UP)
upRotate.play();
else if (event.getCode() == KeyCode.S || event.getCode() == KeyCode.DOWN)
downRotate.play();
};
scene.addEventHandler(KeyEvent.KEY_PRESSED, KeyPressHandler);
EventHandler<KeyEvent> KeyReleaseHandler = event -> {
if (event.getCode() == KeyCode.D || event.getCode() == KeyCode.RIGHT)
rightRotate.stop();
else if (event.getCode() == KeyCode.A || event.getCode() == KeyCode.LEFT)
leftRotate.stop();
else if (event.getCode() == KeyCode.W || event.getCode() == KeyCode.UP)
upRotate.stop();
else if (event.getCode() == KeyCode.S || event.getCode() == KeyCode.DOWN)
downRotate.stop();
};
scene.addEventHandler(KeyEvent.KEY_RELEASED, KeyReleaseHandler);
}
Aggregations