Google is committed to advancing racial equity for Black communities. See how.

TextFieldDelegate

class TextFieldDelegate
kotlin.Any
   ↳ androidx.ui.text.TextFieldDelegate

Summary

Public constructors

Companion functions

TransformedText
applyCompositionDecoration(compositionRange: TextRange, transformed: TransformedText)

Apply the composition text decoration (undeline) to the transformed text.

Unit
draw(canvas: Canvas, value: EditorValue, offsetMap: OffsetMap, textLayoutResult: TextLayoutResult, selectionColor: Color)

Draw the text content to the canvas

Triple<IntPx, IntPx, TextLayoutResult>
layout(textDelegate: TextDelegate, constraints: Constraints, layoutDirection: LayoutDirection, prevResultText: TextLayoutResult? = null)

Process text layout with given constraint.

Unit
notifyFocusedRect(value: EditorValue, textDelegate: TextDelegate, textLayoutResult: TextLayoutResult, layoutCoordinates: LayoutCoordinates, textInputService: TextInputService, token: InputSessionToken, hasFocus: Boolean, offsetMap: OffsetMap)

Notify system that focused input area.

Unit
onBlur(textInputService: TextInputService?, token: InputSessionToken, editProcessor: EditProcessor, hasNextClient: Boolean, onValueChange: (EditorValue) -> Unit)

Called when the composable loses input focus

InputSessionToken
onFocus(textInputService: TextInputService?, value: EditorValue, editProcessor: EditProcessor, keyboardType: KeyboardType, imeAction: ImeAction, onValueChange: (EditorValue) -> Unit, onImeActionPerformed: (ImeAction) -> Unit)

Called when the composable gained input focus

Unit
onRelease(position: PxPosition, textLayoutResult: TextLayoutResult, editProcessor: EditProcessor, offsetMap: OffsetMap, onValueChange: (EditorValue) -> Unit, textInputService: TextInputService?, token: InputSessionToken, hasFocus: Boolean)

Called when onRelease event is fired.

Public constructors

<init>

TextFieldDelegate()

Companion functions

applyCompositionDecoration

fun applyCompositionDecoration(
    compositionRange: TextRange,
    transformed: TransformedText
): TransformedText

Apply the composition text decoration (undeline) to the transformed text.

Parameters
compositionRange: TextRange An input state
transformed: TransformedText A transformed text
Return
The transformed text with composition decoration.

draw

@JvmStatic fun draw(
    canvas: Canvas,
    value: EditorValue,
    offsetMap: OffsetMap,
    textLayoutResult: TextLayoutResult,
    selectionColor: Color
): Unit

Draw the text content to the canvas

Parameters
canvas: Canvas The target canvas.
value: EditorValue The editor state
offsetMap: OffsetMap The offset map
selectionColor: Color The selection color

layout

@JvmStatic fun layout(
    textDelegate: TextDelegate,
    constraints: Constraints,
    layoutDirection: LayoutDirection,
    prevResultText: TextLayoutResult? = null
): Triple<IntPx, IntPx, TextLayoutResult>

Process text layout with given constraint.

Parameters
textDelegate: TextDelegate The text painter
constraints: Constraints The layout constraints
Return
the bounding box size (width and height) of the layout result

notifyFocusedRect

@JvmStatic fun notifyFocusedRect(
    value: EditorValue,
    textDelegate: TextDelegate,
    textLayoutResult: TextLayoutResult,
    layoutCoordinates: LayoutCoordinates,
    textInputService: TextInputService,
    token: InputSessionToken,
    hasFocus: Boolean,
    offsetMap: OffsetMap
): Unit

Notify system that focused input area.

System is typically scrolled up not to be covered by keyboard.

Parameters
value: EditorValue The editor model
textDelegate: TextDelegate The text delegate
layoutCoordinates: LayoutCoordinates The layout coordinates
textInputService: TextInputService The text input service
token: InputSessionToken The current input session token.
hasFocus: Boolean True if focus is gained.
offsetMap: OffsetMap The mapper from/to editing buffer to/from visible text.

onBlur

@JvmStatic fun onBlur(
    textInputService: TextInputService?,
    token: InputSessionToken,
    editProcessor: EditProcessor,
    hasNextClient: Boolean,
    onValueChange: (EditorValue) -> Unit
): Unit

Called when the composable loses input focus

Parameters
textInputService: TextInputService? The text input service
token: InputSessionToken The current input session token.
editProcessor: EditProcessor The edit processor
onValueChange: (EditorValue) -> Unit The callback called when the new editor state arrives.

onFocus

@JvmStatic fun onFocus(
    textInputService: TextInputService?,
    value: EditorValue,
    editProcessor: EditProcessor,
    keyboardType: KeyboardType,
    imeAction: ImeAction,
    onValueChange: (EditorValue) -> Unit,
    onImeActionPerformed: (ImeAction) -> Unit
): InputSessionToken

Called when the composable gained input focus

Parameters
textInputService: TextInputService? The text input service
value: EditorValue The editor state
editProcessor: EditProcessor The edit processor
keyboardType: KeyboardType The keyboard type
onValueChange: (EditorValue) -> Unit The callback called when the new editor state arrives.
onImeActionPerformed: (ImeAction) -> Unit The callback called when the editor action arrives.

onRelease

@JvmStatic fun onRelease(
    position: PxPosition,
    textLayoutResult: TextLayoutResult,
    editProcessor: EditProcessor,
    offsetMap: OffsetMap,
    onValueChange: (EditorValue) -> Unit,
    textInputService: TextInputService?,
    token: InputSessionToken,
    hasFocus: Boolean
): Unit

Called when onRelease event is fired.

Parameters
position: PxPosition The event position in composable coordinate.
textLayoutResult: TextLayoutResult The text layout result
editProcessor: EditProcessor The edit processor
offsetMap: OffsetMap The offset map
onValueChange: (EditorValue) -> Unit The callback called when the new editor state arrives.
textInputService: TextInputService? The text input service
token: InputSessionToken The current input session token.
hasFocus: Boolean True if the composable has input focus, otherwise false.