當前位置: 首頁>>代碼示例>>Java>>正文


Java TextInputControl.isFocused方法代碼示例

本文整理匯總了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);
        }
    }
}
 
開發者ID:ben12,項目名稱:infxnity,代碼行數:38,代碼來源:MaskTextFilter.java

示例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);
}
 
開發者ID:kasemir,項目名稱:org.csstudio.display.builder,代碼行數:34,代碼來源:AutocompleteMenu.java

示例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);
  }
}
 
開發者ID:comtel2000,項目名稱:fx-experience,代碼行數:12,代碼來源:FXOK.java


注:本文中的javafx.scene.control.TextInputControl.isFocused方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。