本文整理汇总了Java中javafx.scene.control.TextInputControl.isFocused方法的典型用法代码示例。如果您正苦于以下问题:Java TextInputControl.isFocused方法的具体用法?Java TextInputControl.isFocused怎么用?Java TextInputControl.isFocused使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.TextInputControl
的用法示例。
在下文中一共展示了TextInputControl.isFocused方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: install
import javafx.scene.control.TextInputControl; //导入方法依赖的package包/类
/**
* @param input
* {@link TextInputControl} where set the default value
* @param setDefaultOnFocus
* true to set the default value when it gain the focus, otherwise the default value is immediately applied
*/
public void install(final TextInputControl input, final boolean setDefaultOnFocus)
{
if (input != null)
{
if (!setDefaultOnFocus)
{
applyDefault(input);
}
else
{
final ChangeListener<Boolean> focusListener = new ChangeListener<Boolean>()
{
@Override
public void changed(final ObservableValue<? extends Boolean> observable, final Boolean oldValue,
final Boolean newValue)
{
if ((observable == input.focusedProperty() && newValue && !input.isPressed())
|| (observable == input.pressedProperty() && !newValue && input.isFocused()))
{
applyDefault(input);
input.focusedProperty().removeListener(this);
input.pressedProperty().removeListener(this);
}
}
};
input.focusedProperty().addListener(focusListener);
input.pressedProperty().addListener(focusListener);
}
}
}
示例2: ControlWrapper
import javafx.scene.control.TextInputControl; //导入方法依赖的package包/类
ControlWrapper(final TextInputControl field)
{
this.field = field;
focused_listener = (obs, oldval, newval) ->
{
menu.hide();
if (newval)
current_field = field;
};
text_listener = (obs, oldval, newval) ->
{
if (field.isFocused())
{
//TODO: could make use of cursor position for more intelligent suggestions
if (updater != null)
updater.requestEntries(field.getText());
if (!menu.isShowing())
menu.show(field, Side.BOTTOM, 0, 0);
}
};
submit_handler = (event) ->
{
if (event.getCode() == KeyCode.ENTER)
updateHistory(field.getText());
};
field.focusedProperty().addListener(focused_listener);
field.addEventHandler(KeyEvent.KEY_RELEASED, submit_handler);
field.textProperty().addListener(text_listener);
}
示例3: updateVisibilty
import javafx.scene.control.TextInputControl; //导入方法依赖的package包/类
public static void updateVisibilty(Scene scene, TextInputControl textInput) {
if (textInput.isEditable() && textInput.isFocused()) {
setVisible(Visiblity.SHOW, textInput);
} else if (scene == null || scene.getWindow() == null || !scene.getWindow().isFocused()
|| !(scene.getFocusOwner() instanceof TextInputControl
&& ((TextInputControl) scene.getFocusOwner()).isEditable())) {
setVisible(Visiblity.HIDE, textInput);
} else {
setVisible(Visiblity.POS, textInput);
}
}