Search in sources :

Example 1 with KeyEvent

use of javafx.scene.input.KeyEvent in project JFoenix by jfoenixadmin.

the class GenericEditableTreeTableCell method createEditorNode.

private void createEditorNode() {
    EventHandler<KeyEvent> keyEventsHandler = new EventHandler<KeyEvent>() {

        @Override
        public void handle(KeyEvent t) {
            if (t.getCode() == KeyCode.ENTER) {
                commitHelper(false);
            } else if (t.getCode() == KeyCode.ESCAPE) {
                cancelEdit();
            } else if (t.getCode() == KeyCode.TAB) {
                commitHelper(false);
                TreeTableColumn nextColumn = getNextColumn(!t.isShiftDown());
                if (nextColumn != null) {
                    getTreeTableView().edit(getIndex(), nextColumn);
                }
            }
        }
    };
    ChangeListener<Boolean> focusChangeListener = new ChangeListener<Boolean>() {

        @Override
        public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) {
            //of stopping the double commit.
            if (!newValue && editorNode != null) {
                commitHelper(true);
            }
        }
    };
    DoubleBinding minWidthBinding = Bindings.createDoubleBinding(() -> {
        return this.getWidth() - this.getGraphicTextGap() * 2 - this.getBaselineOffset();
    }, this.widthProperty(), this.graphicTextGapProperty());
    editorNode = builder.createNode(getValue(), minWidthBinding, keyEventsHandler, focusChangeListener);
}
Also used : KeyEvent(javafx.scene.input.KeyEvent) JFXTreeTableColumn(com.jfoenix.controls.JFXTreeTableColumn) TreeTableColumn(javafx.scene.control.TreeTableColumn) DoubleBinding(javafx.beans.binding.DoubleBinding) ObservableValue(javafx.beans.value.ObservableValue) EventHandler(javafx.event.EventHandler) ChangeListener(javafx.beans.value.ChangeListener)

Example 2 with KeyEvent

use of javafx.scene.input.KeyEvent in project DistributedFractalNetwork by Budder21.

the class LayerCell method createTextField.

private void createTextField() {
    textField = new TextField(getString());
    textField.setOnKeyReleased(new EventHandler<KeyEvent>() {

        @Override
        public void handle(KeyEvent t) {
            if (t.getCode() == KeyCode.ENTER) {
                commitEdit(textField.getText());
            } else if (t.getCode() == KeyCode.ESCAPE) {
                cancelEdit();
            }
        }
    });
}
Also used : KeyEvent(javafx.scene.input.KeyEvent) TextField(javafx.scene.control.TextField)

Example 3 with KeyEvent

use of javafx.scene.input.KeyEvent in project jphp by jphp-compiler.

the class KeyboardManager method trigger.

protected void trigger(boolean down) {
    List<KeyCombination.Modifier> modifiers = new ArrayList<>();
    if (shiftDown) {
        modifiers.add(SHIFT_DOWN);
    }
    if (controlDown) {
        modifiers.add(KeyCombination.CONTROL_DOWN);
    }
    if (altDown) {
        modifiers.add(KeyCombination.ALT_DOWN);
    }
    KeyCombination.Modifier[] modifiersArray = modifiers.toArray(new KeyCombination.Modifier[modifiers.size()]);
    for (Map.Entry<KeyCode, KeyEvent> entry : keys.entrySet()) {
        KeyCode code;
        try {
            code = entry.getKey();
        } catch (IllegalStateException e) {
            continue;
        }
        if (code == null || code == KeyCode.UNDEFINED) {
            continue;
        }
        KeyCodeCombination keyCombination;
        try {
            keyCombination = new KeyCodeCombination(code, modifiersArray);
        } catch (IllegalArgumentException e) {
            continue;
        }
        trigger(keyCombination, down);
        if (modifiersArray.length > 0) {
            keyCombination = new KeyCodeCombination(code);
            trigger(keyCombination, down);
        }
    }
}
Also used : KeyEvent(javafx.scene.input.KeyEvent) KeyCode(javafx.scene.input.KeyCode) KeyCodeCombination(javafx.scene.input.KeyCodeCombination) KeyCombination(javafx.scene.input.KeyCombination)

Example 4 with KeyEvent

use of javafx.scene.input.KeyEvent in project jphp by jphp-compiler.

the class UXKeyboardManager method onDown.

@Signature
public void onDown(KeyCombination keys, Invoker handler, String group, Environment env) {
    EventHandler<KeyEvent> onDown = getWrappedObject().getOnDown(keys);
    if (onDown == null) {
        onDown = new ScriptEventHandler<>(env);
        getWrappedObject().setOnDown(keys, onDown);
    }
    ScriptEventHandler eventHandler = (ScriptEventHandler) onDown;
    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 5 with KeyEvent

use of javafx.scene.input.KeyEvent in project jphp by jphp-compiler.

the class UXKeyboardManager method onUp.

@Signature
public void onUp(KeyCombination keys, Invoker handler, String group, Environment env) {
    EventHandler<KeyEvent> onUp = getWrappedObject().getOnUp(keys);
    if (onUp == null) {
        onUp = new ScriptEventHandler<>(env);
        getWrappedObject().setOnUp(keys, onUp);
    }
    ScriptEventHandler eventHandler = (ScriptEventHandler) onUp;
    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)

Aggregations

KeyEvent (javafx.scene.input.KeyEvent)40 ObservableValue (javafx.beans.value.ObservableValue)9 KeyCode (javafx.scene.input.KeyCode)9 Scene (javafx.scene.Scene)8 Test (org.junit.Test)8 Stage (javafx.stage.Stage)7 Application (javafx.application.Application)6 ChangeListener (javafx.beans.value.ChangeListener)6 EventHandler (javafx.event.EventHandler)6 TextField (javafx.scene.control.TextField)6 IOException (java.io.IOException)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 Insets (javafx.geometry.Insets)4 Tooltip (javafx.scene.control.Tooltip)4 Image (javafx.scene.image.Image)4