private void initialize() { this.getStyleClass().add(DEFAULT_STYLE_CLASS); try { editorProperty(); Field editorField = DatePicker.class.getDeclaredField("editor"); editorField.setAccessible(true); ReadOnlyObjectWrapper<TextField> editor = (ReadOnlyObjectWrapper<TextField>) editorField.get(this); final FakeFocusJFXTextField editorNode = new FakeFocusJFXTextField(); this.focusedProperty().addListener((obj, oldVal, newVal) -> { if (getEditor() != null) { editorNode.setFakeFocus(newVal); } }); editorNode.activeValidatorWritableProperty().bind(activeValidatorProperty()); editor.set(editorNode); } catch (NoSuchFieldException e) { } catch (IllegalAccessException e) { } }
public void setFakeFocus(boolean b) { setFocused(b); }
public final ReadOnlyObjectProperty<TextField> editorProperty() { if (editor == null) { editor = new ReadOnlyObjectWrapper<>(this, "editor"); final FakeFocusJFXTextField editorNode = new FakeFocusJFXTextField(); this.focusedProperty().addListener((obj, oldVal, newVal) -> { if (getEditor() != null) { editorNode.setFakeFocus(newVal); } }); editorNode.activeValidatorWritableProperty().bind(activeValidatorProperty()); editor.set(editorNode); } return editor.getReadOnlyProperty(); }
@Override public Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters) { switch (attribute) { case FOCUS_ITEM: // keep focus on parent control return getParent(); default: return super.queryAccessibleAttribute(attribute, parameters); } }
public void setFakeFocus(boolean b) { setFocused(b); }
private void initialize() { this.getStyleClass().add(DEFAULT_STYLE_CLASS); editorProperty(); ReadOnlyObjectWrapper<TextField> editor = ReflectionHelper.getFieldContent(DatePicker.class, this, "editor" ); final FakeFocusJFXTextField editorNode = new FakeFocusJFXTextField(); this.focusedProperty().addListener((obj, oldVal, newVal) -> { if (getEditor() != null) { editorNode.setFakeFocus(newVal); } }); editorNode.activeValidatorWritableProperty().bind(activeValidatorProperty()); editor.set(editorNode); }
public final ReadOnlyObjectProperty<TextField> editorProperty() { if (editor == null) { editor = new ReadOnlyObjectWrapper<>(this, "editor"); final FakeFocusJFXTextField editorNode = new FakeFocusJFXTextField(); this.focusedProperty().addListener((obj, oldVal, newVal) -> { if (getEditor() != null) { editorNode.setFakeFocus(newVal); } }); editorNode.activeValidatorWritableProperty().bind(activeValidatorProperty()); editor.set(editorNode); } return editor.getReadOnlyProperty(); }
@Override public Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters) { switch (attribute) { case FOCUS_ITEM: // keep focus on parent control return getParent(); default: return super.queryAccessibleAttribute(attribute, parameters); } }