InteractiveComponent

data class InteractiveComponent(val id: InteractiveId, val scrollIndex: Int?, layoutCoordinates: LayoutCoordinates?, val visualTextRange: TextRange, val textMapping: TextMapping, val textLayoutResult: TextLayoutResult?, val userData: UserData = UserData.empty)

Class representing an interactive GUI element. Best created in onGloballyPositioned modifier.

Constructors

Link copied to clipboard
constructor(id: InteractiveId, scrollIndex: Int?, layoutCoordinates: LayoutCoordinates?, visualTextRange: TextRange, textMapping: TextMapping, textLayoutResult: TextLayoutResult?, userData: UserData = UserData.empty)

Properties

Link copied to clipboard
val attachedLayoutCoordinates: LayoutCoordinates?
Link copied to clipboard

True if the component contains any text. False otherwise.

Link copied to clipboard

ID of the interactive component. The IDs must follow the flow of the text, because they are used to sort the components in line order. This is important for cursor navigation and selection.

Link copied to clipboard
Link copied to clipboard

True if the text contained in this component has more than one line. False if the component has no text or the contained text is just one line.

Link copied to clipboard

If the component is placed inside LazyColumn or LazyRow, this is the item index in that container. It is used if you want to scroll to a particular component. Does not need to be unique, more components can be placed in a single LazyList.item.

Link copied to clipboard
val textLayoutResult: TextLayoutResult?

Result of laying out the text if this is a component displaying text. Used for cursor movement.

Link copied to clipboard

Maps ranges of displayed text to ranges of source text and vice-versa. Useful for writing editors.

Link copied to clipboard

Any kind of data one might want to attach to this component.

Link copied to clipboard
val visualTextRange: TextRange

Text range of the displayed text if the represented component is a component displaying text.

Functions

Link copied to clipboard
inline operator fun <T : Any> get(type: KClass<T>): T

Reads user data.

Link copied to clipboard
inline fun <T : Any> hasData(): Boolean

Check if user data of the specified type are attached.

Link copied to clipboard
fun <T : Any> withData(type: KClass<T>, value: T): InteractiveComponent

Creates a new instance of this component with the user data attached.