# Interface WaylandTextInput

All Superinterfaces:
  `AutoCloseable, Closeable`

public sealed interface WaylandTextInput extends Closeable
Abstraction layer between Wayland text input protocols.

WARNING: Text input using this interface is purely complementary to text input via XKB. Certain IMEs such as plasma-keyboard will not emit events for most key presses. In other words, key presses performed through `LinuxFFMKeys.LinuxKeyCallback` are similar to `WaylandTextInput.IMEListener.commitText(String)`.

## Nested Class Summary

Nested Classes
Modifier and Type
Interface
Description
`static interface`
`WaylandTextInput.IMEListener`
Interface describing a listener for `WaylandTextInput`.
`static enum`
`WaylandTextInput.InputChangeCause`
An enumeration describing valid reasons for repeatedly calling `enableTextInput(int, int, int, int, InputChangeCause)` or similar methods.

## Method Summary

Modifier and Type
Method
Description
`void`
`close()`
Destroy the `WaylandTextInput` instance, making further use of it no longer valid.
`void`
`disableTextInput()`
Disable text input, hiding the text editor surface if applicable (how exactly this shows up in practice depends on the used input method and wayland compositor - in other words, it is highly system-specific).
`default void`
`enableTextInput(int cursorX, int cursorY, int width, int height)`
Enable text input, showing the text editor surface if applicable (how exactly this shows up in practice depends on the used input method and wayland compositor - in other words, it is highly system-specific).
`void`
`enableTextInput(int cursorX, int cursorY, int width, int height, @NotNull WaylandTextInput.InputChangeCause cause)`
Enable text input, showing the text editor surface if applicable (how exactly this shows up in practice depends on the used input method and wayland compositor - in other words, it is highly system-specific).
`void`
`setCallback(@NotNull WaylandTextInput.IMEListener listener)`
Set the current callback of this `WaylandTextInput` instance.

## Method Details

### close

void close()
Destroy the `WaylandTextInput` instance, making further use of it no longer valid.

This method should only be called on application shutdown, as there is no way to obtain another instance of `WaylandTextInput`.

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Closeable`

### disableTextInput

void disableTextInput()
Disable text input, hiding the text editor surface if applicable (how exactly this shows up in practice depends on the used input method and wayland compositor - in other words, it is highly system-specific).

### enableTextInput

default void enableTextInput(int cursorX, int cursorY, int width, int height)
Enable text input, showing the text editor surface if applicable (how exactly this shows up in practice depends on the used input method and wayland compositor - in other words, it is highly system-specific).

The cursor location is used to smartly choose the location of text input aids.

This method commits the text input state to the wayland compositor, unless no changes have been made (and the cursor location and the input is already enabled), at which point nothing gets committed. Committing the state to the wayland compositor with every frame confuses plasma-keyboard (causing it to not display the text editor surface), which is why jxkbwayland aggressively filters out unneeded commits to the compositor.

Parameters:
  `cursorX` - The X-coordinate of the cursor in surface coordinates.
  `cursorY` - The Y-coordinate of the cursor in surface coordinates.
  `width` - The width of the cursor.
  `height` - The height of the cursor.

### enableTextInput

void enableTextInput(int cursorX, int cursorY, int width, int height, @NotNull @NotNull WaylandTextInput.InputChangeCause cause)
Enable text input, showing the text editor surface if applicable (how exactly this shows up in practice depends on the used input method and wayland compositor - in other words, it is highly system-specific).

The cursor location is used to smartly choose the location of text input aids.

This method commits the text input state to the wayland compositor, unless no changes have been made (and the cursor location and the input is already enabled), at which point nothing gets committed. Committing the state to the wayland compositor with every frame confuses plasma-keyboard (causing it to not display the text editor surface), which is why jxkbwayland aggressively filters out unneeded commits to the compositor.

Parameters:
  `cursorX` - The X-coordinate of the cursor in surface coordinates.
  `cursorY` - The Y-coordinate of the cursor in surface coordinates.
  `width` - The width of the cursor.
  `height` - The height of the cursor.
  `cause` - The cause why the cursor changed position. Should be `WaylandTextInput.InputChangeCause.OTHER` if the cursor didn't move, most likely.

### setCallback

void setCallback(@NotNull @NotNull WaylandTextInput.IMEListener listener)
Set the current callback of this `WaylandTextInput` instance.

Parameters:
  `listener` - The callback to register. Note: some events might not get called depending on the underlying protocol used.