scoop:scoop.window:0.1.0
src/accessibility/grid_actions.scoop
Selected production source · src/accessibility/grid_actions.scoop
1
package scoop.window.accessibility3
internal fun performGridCell(4
source: SemanticCollectionSnapshot,5
actions: SemanticGridActions?,6
row: SemanticItemKey,7
column: Long,8
operation: Int9
): SemanticActionResult {10
val grid = source.grid ?: return SemanticActionResult.Unsupported11
if (column < 0L || column >= grid.columns.size)12
return SemanticActionResult.Unavailable13
val key = grid.columns[column].key14
val cell =15
when (source.cellForKey(row, key)) {16
case Found(val value) -> value17
else -> return SemanticActionResult.Unavailable18
}19
if (!cell.properties.enabled)20
return SemanticActionResult.Rejected21
if ((operation == 14 || operation == 15) && !cell.properties.focusable)22
return SemanticActionResult.Unsupported23
val callbacks = actions ?: return SemanticActionResult.Unsupported24
return when (operation) {25
case 12 -> callbacks.realize?.invoke(row, cell.key) ?: SemanticActionResult.Unsupported26
case 13 -> callbacks.reveal?.invoke(row, cell.key) ?: SemanticActionResult.Unsupported27
case 14 -> callbacks.focus?.invoke(row, cell.key, true) ?: SemanticActionResult.Unsupported28
case 15 -> callbacks.focus?.invoke(row, cell.key, false) ?: SemanticActionResult.Unsupported29
else -> SemanticActionResult.Unsupported30
}31
}