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);
}
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();
}
}
});
}
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);
}
}
}
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);
}
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);
}
Aggregations