Keyboard Maliit

The library allows you to control the Maliit keyboard.

Permissions

You must take the library with you maliit-glib.

Features:

  • Keyboard open/close, input type selection.
  • Check is open keyboard / get keyboard height.
  • Push editor state (surrounding text, cursor, selection, input flags) to the input method.
  • Listen state (height/visibility), committed text, preedit updates, raw key events and hide requests.
  • Reset / copy-paste state / rotate keyboard.

Example

// Listen state (height/visibility)
val stateId = Keyboard.listenState { id, event ->
    println(event)
}

// Listen committed text, preedit updates and raw key events
val commitId = Keyboard.listenCommit { id, event -> println(event.text) }
val preeditId = Keyboard.listenPreedit { id, event -> println(event.text) }
val keyId = Keyboard.listenKey { id, event -> println(event) }

// Listen hide requests (swipe-down, activation lost)
val hideId = Keyboard.listenHide { id -> Keyboard.close() }

// Open with Email input mode (or Keyboard.open() for the default Text layout)
Keyboard.openType(KeyboardType.Email)
println("isOpen=${Keyboard.isOpen()}, height=${Keyboard.height()}")

// Push the full editor state (e.g. after the focused field's text changed)
Keyboard.updateState(
    EditorState(surroundingText = "hello", cursorPosition = 5, contentType = KeyboardType.Email),
    focusChanged = true,
)

// Notify the input method about an app-side preedit change, then reset it
Keyboard.setPreedit(text = "wor", cursorPos = 3)
Keyboard.reset()

// Report copy/paste availability to the toolbar
Keyboard.setCopyPasteState(copyAvailable = true, pasteAvailable = false)

// Re-show without re-sending widget info, re-activate after returning to foreground
Keyboard.show()
Keyboard.activate()

// Rotate on orientation change
Keyboard.rotate(90)

// Cleanup
Keyboard.unlistenState(stateId)
Keyboard.unlistenStateAll()
Keyboard.unlistenIme(commitId)
Keyboard.unlistenIme(preeditId)
Keyboard.unlistenIme(keyId)
Keyboard.unlistenIme(hideId)
Keyboard.unlistenImeAll()
Keyboard.close()