Class PreeditEvent

java.lang.Object
limn.scene.event.InputEvent
limn.scene.event.PreeditEvent

public final class PreeditEvent extends InputEvent
In-progress IME composition ("preedit"): the text an input method is still composing, shown inline with an underline but not committed to the editing model. The committed result arrives later as ordinary CharEvents; preedit is purely the transient overlay shown while the user is composing (e.g. typing romaji/pinyin before picking a candidate).

An empty event clears the composition (the user committed or cancelled it). Routed to the focused widget only; a preedit with nothing focused is dropped.

Part of the composing text may be the target: the stretch the input method is converting now, which the user picks a candidate for, drawn differently from the rest. targetStart() and targetLength() say where it is. Every index carried here (caret, the target) is in code points, matching the platform IME.

  • Constructor Details

    • PreeditEvent

      public PreeditEvent(@Nullable String text, int caret, int targetStart, int targetLength)
      An IME composition update. Empty text ends the composition.
      Parameters:
      text - the composing text; null is empty
      caret - caret position within text, in code points
      targetStart - where the stretch being converted starts, in code points
      targetLength - its length in code points; 0 when nothing is being converted
  • Method Details

    • text

      public String text()
      The composing text; empty when the composition ends (commit or cancel).
    • targetStart

      public int targetStart()
      Where the stretch being converted starts within text(), in code points.
    • targetLength

      public int targetLength()
      How long the stretch being converted is, in code points; 0 when there is none.
    • caret

      public int caret()
      Caret position within text(), in code points.
    • isEmpty

      public boolean isEmpty()
      Returns:
      whether the composition is empty (i.e. this event clears the preedit)
    • toString

      public String toString()
      Overrides:
      toString in class Object