Scoop API

scoop:scoop.window:0.1.0

src/accessibility/grid_actions.scoop

Selected production source · src/accessibility/grid_actions.scoop

1package scoop.window.accessibility
3internal fun performGridCell(
4 source: SemanticCollectionSnapshot,
5 actions: SemanticGridActions?,
6 row: SemanticItemKey,
7 column: Long,
8 operation: Int
9): SemanticActionResult {
10 val grid = source.grid ?: return SemanticActionResult.Unsupported
11 if (column < 0L || column >= grid.columns.size)
12 return SemanticActionResult.Unavailable
13 val key = grid.columns[column].key
14 val cell =
15 when (source.cellForKey(row, key)) {
16 case Found(val value) -> value
17 else -> return SemanticActionResult.Unavailable
18 }
19 if (!cell.properties.enabled)
20 return SemanticActionResult.Rejected
21 if ((operation == 14 || operation == 15) && !cell.properties.focusable)
22 return SemanticActionResult.Unsupported
23 val callbacks = actions ?: return SemanticActionResult.Unsupported
24 return when (operation) {
25 case 12 -> callbacks.realize?.invoke(row, cell.key) ?: SemanticActionResult.Unsupported
26 case 13 -> callbacks.reveal?.invoke(row, cell.key) ?: SemanticActionResult.Unsupported
27 case 14 -> callbacks.focus?.invoke(row, cell.key, true) ?: SemanticActionResult.Unsupported
28 case 15 -> callbacks.focus?.invoke(row, cell.key, false) ?: SemanticActionResult.Unsupported
29 else -> SemanticActionResult.Unsupported
30 }