Search in sources :

Example 36 with KeyEvent

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);
}
Also used : KeyEvent(javafx.scene.input.KeyEvent) ScriptEventHandler(org.develnext.jphp.ext.javafx.support.ScriptEventHandler) Signature(php.runtime.annotation.Reflection.Signature)

Example 37 with KeyEvent

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);
    }
}
Also used : KeyEvent(javafx.scene.input.KeyEvent)

Example 38 with KeyEvent

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);
            }
        }
    }
}
Also used : KeyEvent(javafx.scene.input.KeyEvent) Event(javafx.event.Event) KeyEvent(javafx.scene.input.KeyEvent)

Example 39 with KeyEvent

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();
                }
            });
        }
    });
}
Also used : KeyEvent(javafx.scene.input.KeyEvent) BusyPane(jgnash.uifx.control.BusyPane) Insets(javafx.geometry.Insets) ObservableValue(javafx.beans.value.ObservableValue) IOException(java.io.IOException) SpinnerValueFactory(javafx.scene.control.SpinnerValueFactory) FXML(javafx.fxml.FXML) InjectFXML(jgnash.uifx.util.InjectFXML)

Example 40 with KeyEvent

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);
}
Also used : KeyEvent(javafx.scene.input.KeyEvent) EventHandler(javafx.event.EventHandler) FontWeight(javafx.scene.text.FontWeight) Scene(javafx.scene.Scene) MouseButton(javafx.scene.input.MouseButton) java.util(java.util) Point3D(javafx.geometry.Point3D) javafx.scene.control(javafx.scene.control) Rotate(javafx.scene.transform.Rotate) MouseEvent(javafx.scene.input.MouseEvent) FXCollections(javafx.collections.FXCollections) TextFieldTableCell(javafx.scene.control.cell.TextFieldTableCell) Application(javafx.application.Application) TextAlignment(javafx.scene.text.TextAlignment) RotateTransition(javafx.animation.RotateTransition) PrintWriter(java.io.PrintWriter) KeyCode(javafx.scene.input.KeyCode) HBox(javafx.scene.layout.HBox) Color(javafx.scene.paint.Color) KeyFrame(javafx.animation.KeyFrame) PropertyValueFactory(javafx.scene.control.cell.PropertyValueFactory) Font(javafx.scene.text.Font) FileWriter(java.io.FileWriter) Timeline(javafx.animation.Timeline) ImagePattern(javafx.scene.paint.ImagePattern) Rectangle(javafx.scene.shape.Rectangle) IOException(java.io.IOException) KeyEvent(javafx.scene.input.KeyEvent) Group(javafx.scene.Group) File(java.io.File) Text(javafx.scene.text.Text) Duration(javafx.util.Duration) Interpolator(javafx.animation.Interpolator) Stage(javafx.stage.Stage) ObservableList(javafx.collections.ObservableList) Image(javafx.scene.image.Image) Point3D(javafx.geometry.Point3D) RotateTransition(javafx.animation.RotateTransition)

Aggregations

KeyEvent (javafx.scene.input.KeyEvent)41 KeyCode (javafx.scene.input.KeyCode)10 ObservableValue (javafx.beans.value.ObservableValue)9 Scene (javafx.scene.Scene)8 Test (org.junit.Test)8 TextField (javafx.scene.control.TextField)7 Stage (javafx.stage.Stage)7 Application (javafx.application.Application)6 ChangeListener (javafx.beans.value.ChangeListener)6 EventHandler (javafx.event.EventHandler)6 IOException (java.io.IOException)5 Insets (javafx.geometry.Insets)5 KeyCombination (javafx.scene.input.KeyCombination)5 MouseEvent (javafx.scene.input.MouseEvent)5 Pane (javafx.scene.layout.Pane)5 List (java.util.List)4 Event (javafx.event.Event)4 FXML (javafx.fxml.FXML)4 Label (javafx.scene.control.Label)4 Tooltip (javafx.scene.control.Tooltip)4