InputMethodEvent (JavaFX 13)

Module javafx.graphics
Package javafx.scene.input

## Class InputMethodEvent

- java.lang.Object
- - java.util.EventObject
  - - javafx.event.Event
    - - javafx.scene.input.InputEvent
      - - javafx.scene.input.InputMethodEvent

- All Implemented Interfaces:
    `Serializable`, `Cloneable`

      public final class InputMethodEvent
      extends InputEvent

  An event which indicates that the underlying input method notifies its text change in a `Node`.

  This event is delivered to the `Node` object that extends `TextInputControl`, when the text under composition (composed text) is generated/changed/removed, the input method commits the result text, or the input method caret position changes.

  On receiving this event, the application is supposed to display the composed text with any visual feedback attributes to the user.

  Note: this is a conditional feature. See `ConditionalFeature.INPUT_METHOD` for more information.

  Since:
    JavaFX 2.0
  See Also:
    Serialized Form

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `static EventType<InputMethodEvent>` | `ANY` | Common supertype for all input method event types.
    `static EventType<InputMethodEvent>` | `INPUT_METHOD_TEXT_CHANGED` | The only valid EventType for the InputMethodEvent.

    - ### Fields inherited from class javafx.event.Event

      `consumed, eventType, NULL_SOURCE_TARGET, target`

    - ### Fields inherited from class java.util.EventObject

      `source`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `InputMethodEvent​(Object source, EventTarget target, EventType<InputMethodEvent> eventType, List<InputMethodTextRun> composed, String committed, int caretPosition)` | Constructs new InputMethodEvent event.
    `InputMethodEvent​(EventType<InputMethodEvent> eventType, List<InputMethodTextRun> composed, String committed, int caretPosition)` | Constructs new InputMethodEvent event with empty source and target.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `InputMethodEvent` | `copyFor​(Object newSource, EventTarget newTarget)` | Creates and returns a copy of this event with the specified event source and target.
    `int` | `getCaretPosition()` | The input method caret position within the composed text.
    `String` | `getCommitted()` | Gets the text that is committed by the input method as the result of the composition.
    `ObservableList<InputMethodTextRun>` | `getComposed()` | Gets the text under composition.
    `EventType<InputMethodEvent>` | `getEventType()` | Gets the event type of this event.
    `String` | `toString()` | Returns a string representation of this `InputMethodEvent` object.

    - ### Methods inherited from class javafx.event.Event

      `clone, consume, fireEvent, getTarget, isConsumed`

    - ### Methods inherited from class java.util.EventObject

      `getSource`

    - ### Methods inherited from class java.lang.Object

      `equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### INPUT_METHOD_TEXT_CHANGED

          public static final EventType<InputMethodEvent> INPUT_METHOD_TEXT_CHANGED

      The only valid EventType for the InputMethodEvent.

    - #### ANY

          public static final EventType<InputMethodEvent> ANY

      Common supertype for all input method event types.
      Since:
        JavaFX 8.0

  - ### Constructor Detail

    - #### InputMethodEvent

          public InputMethodEvent​(Object source,
                                  EventTarget target,
                                  EventType<InputMethodEvent> eventType,
                                  List<InputMethodTextRun> composed,
                                  String committed,
                                  int caretPosition)

      Constructs new InputMethodEvent event.
      Parameters:
        `source` - the source of the event. Can be null.
        `target` - the target of the event. Can be null.
        `eventType` - The type of the event.
        `composed` - the text under composition
        `committed` - the text that is committed as a result of composition
        `caretPosition` - the current position of the caret.
      Since:
        JavaFX 8.0

    - #### InputMethodEvent

          public InputMethodEvent​(EventType<InputMethodEvent> eventType,
                                  List<InputMethodTextRun> composed,
                                  String committed,
                                  int caretPosition)

      Constructs new InputMethodEvent event with empty source and target.
      Parameters:
        `eventType` - The type of the event.
        `composed` - the text under composition
        `committed` - the text that is committed as a result of composition
        `caretPosition` - the current position of the caret.
      Since:
        JavaFX 8.0

  - ### Method Detail

    - #### getComposed

          public final ObservableList<InputMethodTextRun> getComposed()

      Gets the text under composition. This text should be displayed with the appropriate visual feedback that represents the `InputMethodHighlight`s attached to each run.
      Returns:
        The text under composition

    - #### getCommitted

          public final String getCommitted()

      Gets the text that is committed by the input method as the result of the composition.
      Returns:
        The committed text

    - #### getCaretPosition

          public final int getCaretPosition()

      The input method caret position within the composed text. If the position is -1, the caret should be invisible.
      Returns:
        The input method caret position within the composed text

    - #### toString

          public String toString()

      Returns a string representation of this `InputMethodEvent` object.
      Overrides:
        `toString` in class `EventObject`
      Returns:
        a string representation of this `InputMethodEvent` object.

    - #### copyFor

          public InputMethodEvent copyFor​(Object newSource,
                                          EventTarget newTarget)

      Description copied from class: `Event`
      Creates and returns a copy of this event with the specified event source and target. If the source or target is set to `null`, it is replaced by the `NULL_SOURCE_TARGET` value.
      Overrides:
        `copyFor` in class `Event`
      Parameters:
        `newSource` - the new source of the copied event
        `newTarget` - the new target of the copied event
      Returns:
        the event copy with the new source and target

    - #### getEventType

          public EventType<InputMethodEvent> getEventType()

      Description copied from class: `Event`
      Gets the event type of this event. Objects of the same `Event` class can have different event types. These event types further specify what kind of event occurred.
      Overrides:
        `getEventType` in class `InputEvent`
      Returns:
        the event type