List of usage examples for javafx.scene.input KeyEvent KeyEvent
public KeyEvent(@NamedArg("eventType") EventType<KeyEvent> eventType, @NamedArg("character") String character, @NamedArg("text") String text, @NamedArg("code") KeyCode code, @NamedArg("shiftDown") boolean shiftDown, @NamedArg("controlDown") boolean controlDown, @NamedArg("altDown") boolean altDown, @NamedArg("metaDown") boolean metaDown)
From source file:org.eclipse.jubula.rc.javafx.driver.RobotJavaFXImpl.java
/** * {@inheritDoc} <br>//from www .j a va 2s. c om * <b>* Currently delegates the key type to the Robot </b> */ public void type(final Object graphicsComponent, char c) throws RobotException { Validate.notNull(graphicsComponent, "The graphic component must not be null"); //$NON-NLS-1$ final KeyEvent event = new KeyEvent(KeyEvent.KEY_TYPED, String.valueOf(c), StringUtils.EMPTY, null, false, false, false, false); InterceptorOptions options = new InterceptorOptions(new long[] { AWTEvent.KEY_EVENT_MASK }); IRobotEventConfirmer confirmer = m_interceptor.intercept(options); m_queuer.invokeLater("Type character", new Runnable() { //$NON-NLS-1$ @Override public void run() { final Scene scene; if (graphicsComponent instanceof Stage) { scene = ((Stage) graphicsComponent).getScene(); } else { scene = ((Node) graphicsComponent).getScene(); } Node focusOwner = scene.getFocusOwner(); EventTarget eventTarget = focusOwner != null ? focusOwner : scene; Event.fireEvent(eventTarget, event); } }); confirmer.waitToConfirm(graphicsComponent, new KeyJavaFXEventMatcher(KeyEvent.KEY_TYPED)); }