Java 类javafx.scene.control.TextInputControl 实例源码

项目:infxnity    文件:MaskTextFilter.java   
/**
 * @param input
 *            {@link TextInputControl} where set the default value
 */
public void applyDefault(final TextInputControl input)
{
    try
    {
        settingDefaultOn = input;
        final String defaultText = Stream.of(mask) //
                                         .map(m -> Character.toString(m.getDefault()))
                                         .collect(Collectors.joining());
        input.setText(defaultText);

        final int firstAllowedPosition = IntStream.range(0, mask.length)
                                                  .filter(i -> mask[i].isNavigable())
                                                  .findFirst()
                                                  .orElse(0);
        input.selectRange(firstAllowedPosition, firstAllowedPosition);
    }
    finally
    {
        settingDefaultOn = null;
    }
}
项目:dragdropfx    文件:TextDragListenerContext.java   
private EventHandler<MouseEvent> makeOnButtonDownListener(){
    return new EventHandler<MouseEvent>() {

        @Override
        public void handle(MouseEvent event) {
            if(event.getButton() == MouseButton.PRIMARY){
                HitInfo i = DnDTextInput.getHitInfo((TextInputControl) event.getSource(), event);
                IndexRange r = textInput.getSelection();

                if(DnDTextInput.isInRange(i.getInsertionIndex(), r)){
                    currentSelection = r;
                }

                inClick = true;
            }
        }
    };
}
项目:JavaFX_Tutorial    文件:RecipeBrowserTests.java   
public @Test void shouldCallStringDistanceService() {
    StringDistanceService spiedService = Resolver.resolve(StringDistanceService.class);
    TextInputControl searchInput = lookup("#searchInput").query();

    // given two recipes, one hidden after a search
    searchInput.setText("HOT");
    clickOn("SEARCH");

    assumeNotNull(lookup("Hot Tea").query());
    assumeTrue(lookup("Sandwich").query() == null);

    // when a new search is performed
    searchInput.setText("wich");
    clickOn("SEARCH");

    // then the StringDistanceService should be called once for each entry, present or not
    verify(spiedService, times(2)).distance(matches("wich"), any());
}
项目:openjfx-8u-dev-tests    文件:TextInputBase.java   
private void ctrlBackspaceTest() {
    taTesting = getScene().as(org.jemmy.interfaces.Parent.class, Node.class).lookup(new ByID<TextInputControl>(TextAreaApp.INPUT_AREA_ID + Pages.CtrlBackspaceTest.name())).wrap();
    click(taTesting);
    end();

    String text = getTextFromControl();
    final String initialText = text;
    while (!"".equals(text)) {
        text = deleteLastWord(text);
        taTesting.keyboard().pushKey(Keyboard.KeyboardButtons.BACK_SPACE, CTRL);
        if (isPasswordField()) {
            Assert.assertEquals(initialText, getTextFromControl());
        } else {
            if (!text.equals(getTextFromControl())) {
                out(initialText, text);
            }
            Assert.assertEquals(text, getTextFromControl());
        }
    }
}
项目:openjfx-8u-dev-tests    文件:TextInputBase.java   
private void ctrlDeleteTest() {
    taTesting = getScene().as(org.jemmy.interfaces.Parent.class, Node.class).lookup(new ByID<TextInputControl>(TextAreaApp.INPUT_AREA_ID + Pages.CtrlDeleteTest.name())).wrap();

    click(taTesting);
    home();
    String text = getTextFromControl();
    final String initialText = text;
    while (!"".equals(text)) {
        text = deleteFirstWord(text, true);
        taTesting.keyboard().pushKey(Keyboard.KeyboardButtons.DELETE, CTRL);
        if (isPasswordField()) {
            Assert.assertEquals(initialText, getTextFromControl());
        } else {
            if (!text.equals(getTextFromControl())) {
                out(initialText, text);
            }
            Assert.assertEquals(text, getTextFromControl());
        }
    }
}
项目:openjfx-8u-dev-tests    文件:TextInputBase.java   
protected Wrap<? extends Node> getMenuItem(final String menu) {
    getScene().mouse().click();
    Parent<Node> parent = getScene().as(Parent.class, Node.class);
    final Wrap<? extends TextInputControl> wrap = parent.lookup(TextInputControl.class).wrap();
    wrap.mouse().click(1, wrap.getClickPoint(), MouseButtons.BUTTON3);
    Wrap<? extends Scene> scene_wrap = PopupMenuTest.getPopupSceneWrap();
    Wrap<? extends Node> menu_item = scene_wrap.as(Parent.class, Node.class).lookup(Node.class, new LookupCriteria<Node>() {
        public boolean check(Node node) {
            if (node.getProperties().containsKey(MenuItem.class)) {
                String text = ((MenuItem) node.getProperties().get(MenuItem.class)).getText();
                if (text != null && text.contentEquals(menu)) {
                    return true;
                }
            }
            return false;
        }
    }).wrap();
    return menu_item;
}
项目:openjfx-8u-dev-tests    文件:TextTest.java   
@Test
public void asTest() {
    TextInputControlWrap<? extends TextInputControl> area = new TextInputControlDock(new SceneDock().asParent(),
            TextArea.class).wrap();
    assertTrue(area.is(Text.class));
    area.as(Text.class).clear();
    area.as(Text.class).type("as text");
    assertTrue(area.is(CaretText.class));
    area.as(CaretText.class).clear();
    area.as(CaretText.class).type("as caret text");
    area.as(CaretText.class).to("as", false);
    assertTrue(area.is(SelectionText.class));
    area.as(SelectionText.class).clear();
    area.as(SelectionText.class).type("as selection text");
    area.as(SelectionText.class).select("s[^ ]*n");
    assertFalse(area.is(SubSelectionText.class));
    try {
        area.as(SubSelectionText.class).clear();
        fail("");
    } catch (InterfaceException e) {
        //expected
    }
}
项目:addressbook-level4    文件:MainWindow.java   
/**
 * Sets the accelerator of a MenuItem.
 * @param keyCombination the KeyCombination value of the accelerator
 */
private void setAccelerator(MenuItem menuItem, KeyCombination keyCombination) {
    menuItem.setAccelerator(keyCombination);

    /*
     * TODO: the code below can be removed once the bug reported here
     * https://bugs.openjdk.java.net/browse/JDK-8131666
     * is fixed in later version of SDK.
     *
     * According to the bug report, TextInputControl (TextField, TextArea) will
     * consume function-key events. Because CommandBox contains a TextField, and
     * ResultDisplay contains a TextArea, thus some accelerators (e.g F1) will
     * not work when the focus is in them because the key event is consumed by
     * the TextInputControl(s).
     *
     * For now, we add following event filter to capture such key events and open
     * help window purposely so to support accelerators even when focus is
     * in CommandBox or ResultDisplay.
     */
    getRoot().addEventFilter(KeyEvent.KEY_PRESSED, event -> {
        if (event.getTarget() instanceof TextInputControl && keyCombination.match(event)) {
            menuItem.getOnAction().handle(new ActionEvent());
            event.consume();
        }
    });
}
项目:JVx.javafx    文件:FXTextCellEditor.java   
/**
 * Creates a new instance of {@link TextCellEditorHandler}.
 *
 * @param pCellEditor the cell editor.
 * @param pCellEditorListener the cell editor listener.
 * @param pTextComponent the text component.
 * @param pDataRow the data row.
 * @param pColumnName the column name.
 */
public TextCellEditorHandler(FXTextCellEditor pCellEditor, ICellEditorListener pCellEditorListener, TextInputControl pTextComponent, IDataRow pDataRow, String pColumnName)
{
    super(pCellEditor, pCellEditorListener, pTextComponent, pDataRow, pColumnName);

    // TODO Set a dynamic preferred size based on the datatype and hint
    // in the column definition.
    if (component instanceof TextField)
    {
        ((TextField)component).setPrefColumnCount(10);
    }
    else if (component instanceof TextArea)
    {
        ((TextArea)component).setPrefColumnCount(12);
        ((TextArea)component).setPrefRowCount(4);
    }

    registerFocusChangedListener();
    registerKeyEventFilter();

    textChangedListener = this::onTextChanged;
}
项目:org.csstudio.display.builder    文件:AutocompleteMenu.java   
/**
 * Remove the auto-completed field from the menu's list of monitored
 * controls
 */
public void removeField(final TextInputControl control)
{
    if (current_field != null && current_field.equals(control))
    {
        menu.hide();
        current_field = null;
    }
    synchronized (fields)
    {
        for (ControlWrapper cw : fields)
        {
            if (cw.field.equals(control))
            {
                cw.unbind();
                fields.remove(cw);
                break;
            }
        }
    }
}
项目:javafx-console    文件:TextInputControlStream.java   
TextInputControlStream(final TextInputControl textInputControl, Charset charset) {
  this.charset = charset;
  this.in = new TextInputControlInputStream(textInputControl);
  this.out = new TextInputControlOutputStream(textInputControl);

  textInputControl.addEventFilter(KeyEvent.KEY_PRESSED, e -> {
    if (e.getCode() == KeyCode.ENTER) {
      getIn().enterKeyPressed();
      return;
    }

    if (textInputControl.getCaretPosition() <= getIn().getLastLineBreakIndex()) {
      e.consume();
    }
  });
  textInputControl.addEventFilter(KeyEvent.KEY_TYPED, e -> {
    if (textInputControl.getCaretPosition() < getIn().getLastLineBreakIndex()) {
      e.consume();
    }
  });
}
项目:fx-experience    文件:KeyBoardPopup.java   
/**
 * Adds a FocusListener to Scene and open keyboard on {@link TextInputControl}
 *
 * @param scene
 *          {@link Scene} to connect with the keyboard
 * @param doNotOpen
 *          on hidden keyboard do nothing and on showing keyboard move to current component
 *
 * @see #addGlobalFocusListener()
 */
public void addFocusListener(final Scene scene, boolean doNotOpen) {
  registerScene(scene);
  scene.focusOwnerProperty().addListener((value, n1, n2) -> {
    if (n2 instanceof TextInputControl) {
      setVisible(doNotOpen ? Visiblity.POS : Visiblity.SHOW, (TextInputControl) n2);
    } else if (n2 instanceof Parent) {
      TextInputControl control = findTextInputControl((Parent) n2);
      setVisible(
          (control != null ? (doNotOpen ? Visiblity.POS : Visiblity.SHOW) : Visiblity.HIDE),
          control);
    } else {
      setVisible(Visiblity.HIDE);
    }
  });
}
项目:fwm    文件:StatBlockTabController.java   
public void start(Tab rootLayout, Statblock s, Saveable beSaved) throws Exception {
    log.debug("statBlockTab.start called");
    stat = s;
    this.beSaved = beSaved ;
    log.debug("Stat ID:" + s.getID());
    setAllTexts(stat);

    thingsThatCanChange = new TextInputControl[] {nameText, statBlockText};
    nameText.textProperty().addListener(nameListener);
    for(TextInputControl c: thingsThatCanChange){
        c.setOnKeyReleased(saveEvent);
    }
}
项目:marathonv5    文件:JavaFXElementPropertyAccessor.java   
final public String getCText() {
    if (node instanceof TextInputControl) {
        return null;
    }
    Object o = getAttributeObject(getComponent(), "text");
    if (o == null || !(o instanceof String) || o.equals("")) {
        return null;
    }
    return (String) o;
}
项目:marathonv5    文件:JavaFXElement.java   
public void _clear() {
    verifyCanInteractWithElement();
    if (node instanceof TextInputControl) {
        ((TextInputControl) node).setText("");
    } else {
        throw new UnsupportedCommandException("Clear not supported on " + node.getClass().getName(), null);
    }
}
项目:marathonv5    文件:JavaFXElementFactory.java   
public static void reset() {
    add(Node.class, JavaFXElement.class);
    add(TextInputControl.class, JavaFXTextInputControlElement.class);
    add(HTMLEditor.class, JavaFXHTMLEditor.class);
    add(CheckBox.class, JavaFXCheckBoxElement.class);
    add(ToggleButton.class, JavaFXToggleButtonElement.class);
    add(Slider.class, JavaFXSliderElement.class);
    add(Spinner.class, JavaFXSpinnerElement.class);
    add(SplitPane.class, JavaFXSplitPaneElement.class);
    add(ProgressBar.class, JavaFXProgressBarElement.class);
    add(ChoiceBox.class, JavaFXChoiceBoxElement.class);
    add(ColorPicker.class, JavaFXColorPickerElement.class);
    add(ComboBox.class, JavaFXComboBoxElement.class);
    add(DatePicker.class, JavaFXDatePickerElement.class);
    add(TabPane.class, JavaFXTabPaneElement.class);
    add(ListView.class, JavaFXListViewElement.class);
    add(TreeView.class, JavaFXTreeViewElement.class);
    add(TableView.class, JavaFXTableViewElement.class);
    add(TreeTableView.class, JavaFXTreeTableViewElement.class);
    add(CheckBoxListCell.class, JavaFXCheckBoxListCellElement.class);
    add(ChoiceBoxListCell.class, JavaFXChoiceBoxListCellElement.class);
    add(ComboBoxListCell.class, JavaFXComboBoxListCellElemnt.class);
    add(CheckBoxTreeCell.class, JavaFXCheckBoxTreeCellElement.class);
    add(ChoiceBoxTreeCell.class, JavaFXChoiceBoxTreeCellElement.class);
    add(ComboBoxTreeCell.class, JavaFXComboBoxTreeCellElement.class);
    add(TableCell.class, JavaFXTableViewCellElement.class);
    add(CheckBoxTableCell.class, JavaFXCheckBoxTableCellElement.class);
    add(ChoiceBoxTableCell.class, JavaFXChoiceBoxTableCellElement.class);
    add(ComboBoxTableCell.class, JavaFXComboBoxTableCellElemnt.class);
    add(TreeTableCell.class, JavaFXTreeTableCellElement.class);
    add(CheckBoxTreeTableCell.class, JavaFXCheckBoxTreeTableCell.class);
    add(ChoiceBoxTreeTableCell.class, JavaFXChoiceBoxTreeTableCell.class);
    add(ComboBoxTreeTableCell.class, JavaFXComboBoxTreeTableCell.class);
}
项目:marathonv5    文件:JavaFXTextInputControlElement.java   
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override public boolean marathon_select(String value) {
    TextInputControl tc = (TextInputControl) getComponent();
    Boolean isCellEditor = (Boolean) tc.getProperties().get("marathon.celleditor");
    tc.setText("");
    if (isCellEditor != null && isCellEditor) {
        super.sendKeys(value, JavaAgentKeys.ENTER);
        Cell cell = (Cell) tc.getProperties().get("marathon.cell");
        cell.commitEdit(value);
    } else {
        super.sendKeys(value);
    }
    return true;
}
项目:OftenPorter    文件:TextBinder.java   
public TextBinder(final TextInputControl view)
{
    super(view);

    changeListener = new ChangeListener<String>()
    {
        @Override
        public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue)
        {
            doOnchange(oldValue,newValue);
        }
    };
    view.textProperty().addListener(changeListener);
}
项目:SensorThingsManager    文件:EntityGuiController.java   
public static <T extends Node> T addFieldTo(GridPane gp, int row, String title, T node, boolean fillHeight, boolean editable) {
    gp.getRowConstraints().add(new RowConstraints(Region.USE_PREF_SIZE, Region.USE_COMPUTED_SIZE, Region.USE_PREF_SIZE, Priority.NEVER, VPos.BASELINE, fillHeight));
    gp.add(new Label(title), 0, row);
    gp.add(node, 1, row);
    if (node instanceof TextArea) {
        ((TextArea) node).setPrefRowCount(4);
    }
    if (node instanceof TextInputControl) {
        ((TextInputControl) node).setEditable(editable);
    } else {
        node.setDisable(!editable);
    }
    return node;
}
项目:creacoinj    文件:TextFieldValidator.java   
public TextFieldValidator(TextInputControl control, Predicate<String> validator) {
    this.valid.set(validator.test(control.getText()));
    apply(control, valid.get());
    control.textProperty().addListener((observableValue, prev, current) -> {
        boolean nowValid = validator.test(current);
        if (nowValid == valid.get()) return;
        valid.set(nowValid);
    });
    valid.addListener(o -> apply(control, valid.get()));
}
项目:creacoinj    文件:TextFieldValidator.java   
private static void apply(TextInputControl textField, boolean nowValid) {
    if (nowValid) {
        textField.getStyleClass().remove("validation_error");
    } else {
        textField.getStyleClass().add("validation_error");
    }
}
项目:infxnity    文件:MaskTextFilter.java   
/**
 * @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);
        }
    }
}
项目:legendary-guide    文件:TextFieldValidator.java   
public TextFieldValidator(TextInputControl control, Predicate<String> validator) {
    this.valid.set(validator.test(control.getText()));
    apply(control, valid.get());
    control.textProperty().addListener((observableValue, prev, current) -> {
        boolean nowValid = validator.test(current);
        if (nowValid == valid.get()) return;
        valid.set(nowValid);
    });
    valid.addListener(o -> apply(control, valid.get()));
}
项目:legendary-guide    文件:TextFieldValidator.java   
private static void apply(TextInputControl textField, boolean nowValid) {
    if (nowValid) {
        textField.getStyleClass().remove("validation_error");
    } else {
        textField.getStyleClass().add("validation_error");
    }
}
项目:dragdropfx    文件:DragDropFX.java   
@Override
public Void call(Object p) {
    if(isIgnored(p)){return null;}
    TextInputControl c = (TextInputControl) p;
    DnDPrepare.textinput(c);
    return null;
}
项目:dragdropfx    文件:DnDTextInput.java   
static void onCaretPosition(TextInputControl textinput,
        Dragboard dragboard) {
    int caret = textinput.getCaretPosition();
    String insert = dragboard.getString();

    String t1 = textinput.getText().substring(0, textinput.getCaretPosition());
    String t2 = textinput.getText().substring(textinput.getCaretPosition(), textinput.getText().length());
    textinput.setText(t1 + insert + t2);
    textinput.positionCaret(caret + insert.length());
}
项目:dragdropfx    文件:DnDTextInput.java   
static void onSelectedPosition(TextInputControl textinput,
        Dragboard dragboard) {
    IndexRange selection = textinput.getSelection();
    String t1 = textinput.getText().substring(0, selection.getStart());
    String t2 = textinput.getText().substring(selection.getEnd(), textinput.getText().length());
    textinput.setText(t1 + dragboard.getString() + t2);
}
项目:jmonkeybuilder    文件:EventRedirector.java   
private void redirect(@NotNull final InputEvent event) {

        final EventTarget target = event.getTarget();
        if (target == destination) {
            return;
        } else if (target instanceof TextInputControl) {
            if (event instanceof KeyEvent && UIUtils.isNotHotKey((KeyEvent) event)) {
                if (Config.DEV_DEBUG_JFX_KEY_INPUT) {
                    LOGGER.debug(this, target, ev -> "Key event was skipped because it was from " + ev);
                }
                return;
            }
        }

        final EventType<? extends InputEvent> eventType = event.getEventType();
        final FileEditor currentEditor = editorAreaComponent.getCurrentEditor();

        if (Config.DEV_DEBUG_JFX_KEY_INPUT) {
            LOGGER.debug(this, event, notNull(currentEditor), (red, ev, editor) -> "Key event " + ev.getEventType() +
                    " is inside " + editor.isInside(red.getSceneX(), red.getSceneY(), ev.getClass()));
        }

        if (currentEditor == null || eventType != KeyEvent.KEY_RELEASED && !currentEditor.isInside(getSceneX(), getSceneY(), event.getClass())) {
            return;
        }

        if (Config.DEV_DEBUG_JFX_KEY_INPUT) {
            LOGGER.debug(this, event, ev -> "Redirect event " + ev);
        }

        Event.fireEvent(destination, event.copyFor(event.getSource(), destination));
    }
项目:JavaFX_Tutorial    文件:RecipeBrowserTests.java   
public @Test void shouldNarrowResults() {
    // given a search query
    ((TextInputControl)lookup("#searchInput").query()).setText("HOT");

    // when the search button is clicked
    clickOn("SEARCH");

    // then irrelevant recipes should be removed
    assertNotNull(lookup("Hot Tea").query());
    assertNull(lookup("Sandwich").query());

    // ... and the string distance should be calculated twice to do this
    StringDistanceService spiedService = Resolver.resolve(StringDistanceService.class);
    verify(spiedService, times(2)).distance(any(), any());
}
项目:cryptwallet    文件:TextFieldValidator.java   
public TextFieldValidator(TextInputControl control, Predicate<String> validator) {
    this.valid.set(validator.test(control.getText()));
    apply(control, valid.get());
    control.textProperty().addListener((observableValue, prev, current) -> {
        boolean nowValid = validator.test(current);
        if (nowValid == valid.get()) return;
        valid.set(nowValid);
    });
    valid.addListener(o -> apply(control, valid.get()));
}
项目:cryptwallet    文件:TextFieldValidator.java   
private static void apply(TextInputControl textField, boolean nowValid) {
    if (nowValid) {
        textField.getStyleClass().remove("validation_error");
    } else {
        textField.getStyleClass().add("validation_error");
    }
}
项目:gitember    文件:ChangeListenerHistoryHint.java   
public ChangeListenerHistoryHint(TextInputControl textInputControl, SortedSet<String> entries) {
    this.entries = entries;
    this.textInputControl = textInputControl;


    textInputControl.focusedProperty().addListener(new ChangeListener<Boolean>() {
        @Override
        public void changed(ObservableValue<? extends Boolean> observableValue, Boolean aBoolean, Boolean aBoolean2) {
            entriesPopup.hide();
        }
    });

    textInputControl.textProperty().addListener(this);
}
项目:openjfx-8u-dev-tests    文件:TextInputChanger.java   
protected static Environment getEnvironment(final TextInputControlWrapInterface text_input) {
    Wrap<? extends TextInputControl> wrap = text_input.getWrap();
    if (wrap == null) {
        return Root.ROOT.getEnvironment();
    }
    return wrap.getEnvironment();
}
项目:openjfx-8u-dev-tests    文件:TextInputExternalWrap.java   
public TextInputExternalWrap(Wrap<? extends TextInputControl> _wrap) {
    wrap = _wrap;
    kbd = wrap.keyboard();
    Parent<Node> parent = wrap.as(Parent.class, Node.class);
    textWrap = parent.lookup(Text.class, new LookupCriteria<Text>(){
        public boolean check(Text cntrl) {
            return cntrl.isVisible();
        }
    }).wrap();

    wrap.getControl().requestFocus();
}
项目:openjfx-8u-dev-tests    文件:TextControlTestBase.java   
protected void selectAll() {
    requestFocusOnControl(testedControl);
    new GetAction() {
        @Override
        public void run(Object... os) throws Exception {
            ((TextInputControl) (testedControl.getControl())).selectAll();
        }
    }.dispatch(Root.ROOT.getEnvironment());
}
项目:openjfx-8u-dev-tests    文件:TextControlTestBase.java   
protected Double getWidthValue(Wrap<? extends TextInputControl> textInputWrap) {
    return new GetAction<Double>() {
        @Override
        public void run(Object... os) throws Exception {
            setResult(((TextInputControl) (((Wrap<? extends TextInputControl>) (os[0])).getControl())).getWidth());
        }
    }.dispatch(textInputWrap.getEnvironment(), textInputWrap);
}
项目:openjfx-8u-dev-tests    文件:TextControlTestBase.java   
protected Double getHeightValue(Wrap<? extends TextInputControl> textInputWrap) {
    return new GetAction<Double>() {
        @Override
        public void run(Object... os) throws Exception {
            setResult(((TextInputControl) (((Wrap<? extends TextInputControl>) (os[0])).getControl())).getHeight());
        }
    }.dispatch(textInputWrap.getEnvironment(), textInputWrap);
}
项目:openjfx-8u-dev-tests    文件:TextInputBase.java   
protected void initContext() {
    final Wrap<? extends TextInputControl> wrap = getScene().as(Parent.class, Node.class).lookup(TextInputControl.class).wrap();
    wrap.as(Text.class).clear();
    wrap.as(Text.class).type(SAMPLE_STRING);
    wrap.keyboard().pushKey(KeyboardButtons.A, Utils.isMacOS() ? KeyboardModifiers.META_DOWN_MASK : CTRL);
    new GetAction() {
        @Override
        public void run(Object... os) throws Exception {
            Clipboard.getSystemClipboard().clear();
        }
    }.dispatch(Root.ROOT.getEnvironment());
}
项目:openjfx-8u-dev-tests    文件:TextInputBase.java   
/**
 * Test for textInputControl API by simulating user input
 */
public void textInputControlInput(final String changeName, boolean internal) throws InterruptedException {
    openPage(Pages.InputTest.name());
    Thread.sleep(500);
    Parent<Node> parent = getScene().as(Parent.class, Node.class);

    //Take focus on scene.
    getScene().mouse().click(1, new Point(1, 1));

    final Wrap<? extends TextInputControl> wrap = parent.lookup(TextInputControl.class).wrap();

    //Request focus on control.
    new GetAction() {
        @Override
        public void run(Object... os) throws Exception {
            wrap.getControl().requestFocus();
        }
    }.dispatch(Root.ROOT.getEnvironment());


    final ReporterImpl reporter = new ReporterImpl();
    List<Change<TextInputControlWrapInterface>> text_wrap_input_changers = TextInputChanger.getTextInputWrapChangers(reporter);

    for (final Change<TextInputControlWrapInterface> change : text_wrap_input_changers) {
        if (change.getMarker().startsWith(changeName)) {
            if (internal) {
                applyChange(new TextInputInternalWrap(wrap.getControl()), change, reporter, wrap, true);
            } else {
                applyChange(new TextInputExternalWrap(wrap), change, reporter, wrap, false);
            }
        }
    }

    if (reporter.isFailed()) {
        Assert.fail(reporter.getReason());
    }
}
项目:openjfx-8u-dev-tests    文件:TextInputBase.java   
String getTextFromControl(final TextInputControl cntrl) {
    return new GetAction<String>() {
        @Override
        public void run(Object... os) throws Exception {
            setResult(cntrl.getText());
        }
    }.dispatch(Root.ROOT.getEnvironment());
}