SemanticsConfiguration


Describes the semantic information associated with the owning component

The information provided in the configuration is used to to generate the semantics tree.

Summary

Public constructors

Cmn

Public functions

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

Returns an exact copy of this configuration.

Cmn
open operator Boolean
equals(other: Any?)
Cmn
operator T
<T : Any?> get(key: SemanticsPropertyKey<T>)

Retrieves the value for the given property, if one has been set.

Cmn
T
<T : Any?> getOrElse(key: SemanticsPropertyKey<T>, defaultValue: () -> T)
Cmn
T?
<T : Any?> getOrElseNullable(
    key: SemanticsPropertyKey<T>,
    defaultValue: () -> T?
)
Cmn
open Int
Cmn
open operator Iterator<Map.Entry<SemanticsPropertyKey<*>, Any?>>
Cmn
open operator Unit
<T : Any?> set(key: SemanticsPropertyKey<T>, value: T)
Cmn
open String
Cmn
open Unit

Unset an individual property.

Cmn

Public properties

Boolean
Cmn
Boolean

Whether the semantic information provided by the owning component and all of its descendants should be treated as one logical entity.

Cmn

Extension functions

T?
Cmn

Public constructors

SemanticsConfiguration

SemanticsConfiguration()

Public functions

contains

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

copy

fun copy(): SemanticsConfiguration

Returns an exact copy of this configuration.

equals

open operator fun equals(other: Any?): Boolean

get

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

Retrieves the value for the given property, if one has been set. If a value has not been set, throws IllegalStateException

getOrElse

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

getOrElseNullable

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

hashCode

open fun hashCode(): Int

iterator

open operator fun iterator(): Iterator<Map.Entry<SemanticsPropertyKey<*>, Any?>>

set

open operator fun <T : Any?> set(key: SemanticsPropertyKey<T>, value: T): Unit

toString

open fun toString(): String

unset

@ExperimentalComposeUiApi
open fun <T : Any?> unset(key: SemanticsPropertyKey<T>): Unit

Unset an individual property.

Note: this can only unset properties originally on the same modifier chain, not properties merged from children (for those, use clearAndSetSemantics instead). And because the semantics system processes modifier chains back-to-front, the unset must be ordered earlier on the modifier chain if it's in a separate semantics {} block.

  1. Examples of correct uses (resulting in empty semantics):

Modifier.semantics { heading(); unset(SemanticsProperties.Heading) }
Modifier.semantics { unset(SemanticsProperties.Heading) }.semantics { heading() }
  1. Examples of ineffective, no-op uses (where the heading remains instead of being unset):

  Modifier.semantics { unset(SemanticsProperties.Heading); heading() } // order
Modifier.semantics { heading() }.semantics { unset(SemanticsProperties.Heading) } // order
Box(Modifier.semantics(mergeDescendants = true) { unset(SemanticsProperties.Heading) }) {
Box(Modifier.semantics { heading() }) // not originally on the same modifier chain`
}

3. Examples of complex cases where there is more than one set:

// Result is empty semantics: Modifier.semantics { unset(SemanticsProperties.TestTag) }.testTag("b").testTag("a")

// Result is testTag = "b":` Modifier.testTag("b").semantics { unset(SemanticsProperties.TestTag) }.testTag("a")


        

Public properties

isClearingSemantics

var isClearingSemanticsBoolean

isMergingSemanticsOfDescendants

var isMergingSemanticsOfDescendantsBoolean

Whether the semantic information provided by the owning component and all of its descendants should be treated as one logical entity.

If set to true, the descendants of the owning component's SemanticsNode will merge their semantic information into the SemanticsNode representing the owning component.

Extension functions

getOrNull

fun <T : Any?> SemanticsConfiguration.getOrNull(key: SemanticsPropertyKey<T>): T?