{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

PointerIconKt

public final class PointerIconKt


Summary

Public methods

static final @NonNull PointerIcon

Creates PointerIcon from android.view.PointerIcon

static final @NonNull PointerIcon
PointerIcon(int pointerIconType)

Creates PointerIcon from pointer icon type (see android.view.PointerIcon.getSystemIcon

static final @NonNull Modifier
pointerHoverIcon(
    @NonNull Modifier receiver,
    @NonNull PointerIcon icon,
    boolean overrideDescendants
)

Modifier that lets a developer define a pointer icon to display when the cursor is hovered over the element.

Public methods

PointerIcon

public static final @NonNull PointerIcon PointerIcon(@NonNull PointerIcon pointerIcon)

Creates PointerIcon from android.view.PointerIcon

PointerIcon

public static final @NonNull PointerIcon PointerIcon(int pointerIconType)

Creates PointerIcon from pointer icon type (see android.view.PointerIcon.getSystemIcon

pointerHoverIcon

public static final @NonNull Modifier pointerHoverIcon(
    @NonNull Modifier receiver,
    @NonNull PointerIcon icon,
    boolean overrideDescendants
)

Modifier that lets a developer define a pointer icon to display when the cursor is hovered over the element. When overrideDescendants is set to true, children cannot override the pointer icon using this modifier.

import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material.Text
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.pointer.PointerIcon
import androidx.compose.ui.input.pointer.pointerHoverIcon

Column(Modifier.pointerHoverIcon(PointerIcon.Crosshair)) {
    SelectionContainer {
        Column {
            Text("Selectable text")
            Text(
                modifier = Modifier.pointerHoverIcon(PointerIcon.Hand, true),
                text = "Selectable text with hand"
            )
        }
    }
    Text("Just text with global pointerIcon")
}
Parameters
@NonNull PointerIcon icon

The icon to set

boolean overrideDescendants

when false (by default) descendants are able to set their own pointer icon. If true, all children under this parent will receive the requested pointer icon and are no longer allowed to override their own pointer icon.