Scoop API

scoop:scoop.ui.component:0.1.0

src/combobox/semantics.scoop

Selected production source · src/combobox/semantics.scoop

1package scoop.ui.component
3import scoop.window.accessibility.*
4import scoop.ui.*
6internal fun <T: Equals<T>> comboSelectionSemantics(
7 source: ChoiceSource<T>,
8 selected: Array<T>,
9 multiple: Boolean
10): SemanticCollectionSelection {
11 val keys = ArrayList<SemanticItemKey>()
12 for (value in selected)
13 when (source.indexOfValue(value)) {
14 case Some(val index) -> keys.add(componentSemanticKey(source.keyAt(index)))
15 case None -> {}
16 }
17 return SemanticCollectionSelection(keys.toArray(), multiple)
20/** Values are captured by render, so a published row never reads a changing binding. */
21internal fun <T: Equals<T>> comboItemSemantics(
22 entry: ChoiceEntry<T>,
23 selected: Array<T>,
24 enabled: Boolean
25): SemanticItemProperties? =
26 Some(
27 when (entry) {
28 case Item(val item) -> SemanticItemProperties(
29 name = Some(item.choice.label),
30 enabled = enabled && item.choice.enabled,
31 selected = Some(comboContains(selected, item.choice.value))
32 )
33 case Label(_, val content) -> SemanticItemProperties(name = candidateCaption(content))
34 case Separator(_) -> SemanticItemProperties(name = Some(""))
35 }
36 )