Class InputMethodContext

All Implemented Interfaces:
Proxy
Direct Known Subclasses:
InputMethodContext.InputMethodContext$Impl

@Generated("org.javagi.JavaGI") public abstract class InputMethodContext extends GObject

Base class for input method contexts.

WebKitInputMethodContext defines the interface to implement WebKit input methods. The input methods are used by WebKit, when editable content is focused, to map from key events to Unicode character strings.

An input method may consume multiple key events in sequence and finally output the composed result. This is called preediting, and an input method may provide feedback about this process by displaying the intermediate composition states as preedit text.

Since:
2.28
  • Constructor Details

    • InputMethodContext

      public InputMethodContext(MemorySegment address)
      Create a InputMethodContext instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • InputMethodContext

      public InputMethodContext()
      Create a new InputMethodContext.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the InputMethodContext class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected InputMethodContext asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • filterKeyEvent

      public boolean filterKeyEvent(Event keyEvent)

      Allow keyEvent to be handled by the input method.

      If true is returned, then no further processing should be done for the key event.

      Parameters:
      keyEvent - the key event to filter
      Returns:
      true if the key event was handled, or false otherwise
      Since:
      2.28
    • getInputHints

      public Set<InputHints> getInputHints()
      Get the value of the WebKitInputMethodContext:input-hints property.
      Returns:
      the WebKitInputHints of the input associated with this InputMethodContext
      Since:
      2.28
    • getInputPurpose

      public InputPurpose getInputPurpose()
      Get the value of the WebKitInputMethodContext:input-purpose property.
      Returns:
      the WebKitInputPurpose of the input associated with this InputMethodContext
      Since:
      2.28
    • getPreedit

      public void getPreedit(@Nullable Out<String> text, @Nullable Out<List<InputMethodUnderline>> underlines, @Nullable Out<Integer> cursorOffset)

      Get the pre-edit string and a list of WebKitInputMethodUnderline.

      Get the current pre-edit string for the context, and a list of WebKitInputMethodUnderline to apply to the string. The string will be displayed inserted at cursorOffset.

      Parameters:
      text - location to store the preedit string
      underlines - location to store the underlines as a GList of WebKitInputMethodUnderline
      cursorOffset - location to store the position of cursor in preedit string
      Since:
      2.28
    • notifyCursorArea

      public void notifyCursorArea(int x, int y, int width, int height)
      Notify this InputMethodContext that cursor area changed in input associated.
      Parameters:
      x - the x coordinate of cursor location
      y - the y coordinate of cursor location
      width - the width of cursor area
      height - the height of cursor area
      Since:
      2.28
    • notifyFocusIn

      public void notifyFocusIn()
      Notify this InputMethodContext that input associated has gained focus.
      Since:
      2.28
    • notifyFocusOut

      public void notifyFocusOut()
      Notify this InputMethodContext that input associated has lost focus.
      Since:
      2.28
    • notifySurrounding

      public void notifySurrounding(String text, int length, int cursorIndex, int selectionIndex)

      Notify this InputMethodContext that the context surrounding the cursor has changed.

      If there's no selection selectionIndex is the same as cursorIndex.

      Parameters:
      text - text surrounding the insertion point
      length - the length of text, or -1 if text is nul-terminated
      cursorIndex - the byte index of the insertion cursor within text.
      selectionIndex - the byte index of the selection cursor within text.
      Since:
      2.28
    • reset

      public void reset()

      Reset the context.

      This will typically cause the input to clear the preedit state.

      Since:
      2.28
    • setEnablePreedit

      public void setEnablePreedit(boolean enabled)
      Set whether this InputMethodContext should enable preedit to display feedback.
      Parameters:
      enabled - whether to enable preedit
      Since:
      2.28
    • setInputHints

      public void setInputHints(Set<InputHints> hints)
      Set the value of the WebKitInputMethodContext:input-hints property.
      Parameters:
      hints - a WebKitInputHints
      Since:
      2.28
    • setInputHints

      public void setInputHints(InputHints... hints)
      Set the value of the WebKitInputMethodContext:input-hints property.
      Parameters:
      hints - a WebKitInputHints
      Since:
      2.28
    • setInputPurpose

      public void setInputPurpose(InputPurpose purpose)
      Set the value of the WebKitInputMethodContext:input-purpose property.
      Parameters:
      purpose - a WebKitInputPurpose
      Since:
      2.28
    • committed

      protected void committed(String text)
    • deleteSurrounding

      protected void deleteSurrounding(int offset, int nChars)
    • preeditChanged

      protected void preeditChanged()
    • preeditFinished

      protected void preeditFinished()
    • preeditStarted

      protected void preeditStarted()
    • onCommitted

      Emitted when a complete input sequence has been entered by the user. This can be a single character immediately after a key press or the final result of preediting.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      Since:
      2.28
      See Also:
    • emitCommitted

      public void emitCommitted(String text)
      Emits the "committed" signal. See onCommitted(InputMethodContext.CommittedCallback).
    • onDeleteSurrounding

      Emitted when the input method wants to delete the context surrounding the cursor. If offset is a negative value, it means a position before the cursor.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      Since:
      2.28
      See Also:
    • emitDeleteSurrounding

      public void emitDeleteSurrounding(int offset, int nChars)
      Emits the "delete-surrounding" signal. See onDeleteSurrounding(InputMethodContext.DeleteSurroundingCallback).
    • onPreeditChanged

      Emitted whenever the preedit sequence currently being entered has changed. It is also emitted at the end of a preedit sequence, in which case webkit_input_method_context_get_preedit() returns the empty string.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      Since:
      2.28
      See Also:
    • emitPreeditChanged

      public void emitPreeditChanged()
      Emits the "preedit-changed" signal. See onPreeditChanged(InputMethodContext.PreeditChangedCallback).
    • onPreeditFinished

      Emitted when a preediting sequence has been completed or canceled.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      Since:
      2.28
      See Also:
    • emitPreeditFinished

      public void emitPreeditFinished()
      Emits the "preedit-finished" signal. See onPreeditFinished(InputMethodContext.PreeditFinishedCallback).
    • onPreeditStarted

      Emitted when a new preediting sequence starts.
      Parameters:
      handler - the signal handler
      Returns:
      a signal handler ID to keep track of the signal connection
      Since:
      2.28
      See Also:
    • emitPreeditStarted

      public void emitPreeditStarted()
      Emits the "preedit-started" signal. See onPreeditStarted(InputMethodContext.PreeditStartedCallback).