SemanticsPropertyProvider

Known direct subclasses
SemanticsConfiguration

Describes the semantic information associated with the owning component


Read-only view of semantics properties.

SemanticsConfiguration implements this interface. SemanticsNode.unmergedConfig and SemanticsNode.mergedConfig return it so that hosts can read semantics without mutating them.

Summary

Public functions

Boolean
anyProperty(predicate: (key: SemanticsPropertyKey<*>, Any?) -> Boolean)

Returns true if at least one property in this provider matches predicate.

Cmn
operator Boolean
<T : Any?> contains(key: SemanticsPropertyKey<T>)

Returns whether key is present in this provider.

Cmn
Unit
forEachProperty(action: (key: SemanticsPropertyKey<*>, Any?) -> Unit)

Invokes action for each property key and value in this provider.

Cmn
operator T
<T : Any?> get(key: SemanticsPropertyKey<T>)

Returns the value for key, or throws IllegalStateException if not set.

Cmn
T
<T : Any?> getOrElse(key: SemanticsPropertyKey<T>, defaultValue: () -> T)

Returns the value for key, or runs defaultValue if not set.

Cmn
T?
<T : Any?> getOrElseNullable(
    key: SemanticsPropertyKey<T>,
    defaultValue: () -> T?
)

Returns the value for key, or runs defaultValue if not set.

Cmn

Public properties

Set<SemanticsPropertyKey<*>>

Keys in this provider whose SemanticsPropertyKey.accessibilityExtraKey is non-null.

Cmn
Boolean

Whether this configuration declares that it merges the semantics of its descendants (Modifier.semantics(mergeDescendants = true)).

Cmn

Extension functions

T?

Returns the value for key, or null if not present.

Cmn
Boolean

Returns true if this provider contains at least one key that other does not contain.

Cmn

Public functions

anyProperty

fun anyProperty(predicate: (key: SemanticsPropertyKey<*>, Any?) -> Boolean): Boolean

Returns true if at least one property in this provider matches predicate. Stops at the first match.

Parameters
predicate: (key: SemanticsPropertyKey<*>, Any?) -> Boolean

Predicate invoked with each SemanticsPropertyKey and its associated value.

contains

operator fun <T : Any?> contains(key: SemanticsPropertyKey<T>): Boolean

Returns whether key is present in this provider.

Parameters
key: SemanticsPropertyKey<T>

Property key to check.

Returns
Boolean

true if key is present, false otherwise.

forEachProperty

fun forEachProperty(action: (key: SemanticsPropertyKey<*>, Any?) -> Unit): Unit

Invokes action for each property key and value in this provider.

Parameters
action: (key: SemanticsPropertyKey<*>, Any?) -> Unit

Callback invoked with each SemanticsPropertyKey and its associated value.

get

operator fun <T : Any?> get(key: SemanticsPropertyKey<T>): T

Returns the value for key, or throws IllegalStateException if not set.

Parameters
key: SemanticsPropertyKey<T>

Property key to retrieve.

Returns
T

Value associated with key.

Throws
IllegalStateException

if key is not present.

getOrElse

fun <T : Any?> getOrElse(key: SemanticsPropertyKey<T>, defaultValue: () -> T): T

Returns the value for key, or runs defaultValue if not set.

Parameters
key: SemanticsPropertyKey<T>

Property key to retrieve.

defaultValue: () -> T

Fallback supplier run when key is not present.

Returns
T

Value associated with key, or the result of defaultValue.

getOrElseNullable

fun <T : Any?> getOrElseNullable(
    key: SemanticsPropertyKey<T>,
    defaultValue: () -> T?
): T?

Returns the value for key, or runs defaultValue if not set.

Parameters
key: SemanticsPropertyKey<T>

Property key to retrieve.

defaultValue: () -> T?

Fallback supplier run when key is not present.

Returns
T?

Value associated with key, or the result of defaultValue.

Public properties

accessibilityExtraKeys

val accessibilityExtraKeys: Set<SemanticsPropertyKey<*>>

Keys in this provider whose SemanticsPropertyKey.accessibilityExtraKey is non-null.

Hosts expose these values as accessibility extras. Returns an empty set if there are none.

isMergingSemanticsOfDescendants

val isMergingSemanticsOfDescendants: Boolean

Whether this configuration declares that it merges the semantics of its descendants (Modifier.semantics(mergeDescendants = true)).

This is the declared value only. SemanticsNode.isMergingSemanticsOfDescendants is true only when this value is true and the node was created with SemanticsNode.mergingEnabled.

Extension functions

SemanticsPropertyProvider.getOrNull

@ExperimentalComposeUiHostApi
fun <T : Any?> SemanticsPropertyProvider.getOrNull(
    key: SemanticsPropertyKey<T>
): T?

Returns the value for key, or null if not present.

Parameters
key: SemanticsPropertyKey<T>

Property key to retrieve.

Returns
T?

Value associated with key, or null if not present.

SemanticsPropertyProvider.hasKeysMissingFrom

@ExperimentalComposeUiHostApi
fun SemanticsPropertyProvider.hasKeysMissingFrom(
    other: SemanticsPropertyProvider
): Boolean

Returns true if this provider contains at least one key that other does not contain.

Use this to detect deleted properties between an old and a new configuration of the same node: oldConfig.hasKeysMissingFrom(newConfig). Values are not compared.

Parameters
other: SemanticsPropertyProvider

The provider to check keys against.