diff --git a/tutorials/Accessibility/README.md b/tutorials/Accessibility/README.md new file mode 100644 index 0000000000..bb7127ae57 --- /dev/null +++ b/tutorials/Accessibility/README.md @@ -0,0 +1,61 @@ +# Accessibility support + +## Platform Support + +| Platform | Status | +|----------|-----------------------------------| +| MacOS | Supported | +| Windows | Supported with Java Access Bridge | +| Linux | Not supported | + +## Custom widget with semantic rules + +```kotlin +import androidx.compose.foundation.* +import androidx.compose.foundation.layout.* +import androidx.compose.material.Text +import androidx.compose.runtime.* +import androidx.compose.ui.* +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.semantics.* +import androidx.compose.ui.unit.* +import androidx.compose.ui.window.* + +fun main() = singleWindowApplication( + title = "Custom Button", state = WindowState(size = DpSize(300.dp, 200.dp)) +) { + var count by remember { mutableStateOf(0) } + + Box(modifier = Modifier.padding(50.dp)) { + Box(modifier = Modifier + .background(Color.LightGray) + .fillMaxSize() + .clickable { count += 1 } + .semantics(mergeDescendants = true /* Use text from the contents (1) */) { + // This is a button (2) + role = Role.Button + // Add some help text to button (3) + contentDescription = "Click to increment value" + } + ) { + val text = when (count) { + 0 -> "Click Me!" + 1 -> "Clicked" + else -> "Clicked $count times" + } + Text(text, modifier = Modifier.align(Alignment.Center), fontSize = 24.sp) + } + } +} +``` + +![Custom Widget](./images/custom-widget.png) + +# Windows +Accessibility on Windows is provided by Java Access Bridge and is disabled by default. To enable it, run the following command in Command Prompt. + +```cmd +%JAVA_HOME%\bin\jabswitch.exe /enable +``` + +There are some issues with HiDPI display support on windows, see [Desktop Accessibility on Windows](Windows.md) for details. diff --git a/tutorials/Accessibility/Windows.md b/tutorials/Accessibility/Windows.md new file mode 100644 index 0000000000..5caa90c944 --- /dev/null +++ b/tutorials/Accessibility/Windows.md @@ -0,0 +1,18 @@ +# Desktop Accessibility on Windows + +## Enabling Java Accessibility on Windows +Java Access Bridge is disabled by default. To enable it, run + +```cmd +%JAVA_HOME%\bin\jabswitch.exe /enable +``` + +## HiDPI issues +### JDK support +HiDPI support in Access Bridge was landed in [JDK-8279227](https://bugs.openjdk.java.net/browse/JDK-8279227). As for Feb/01/2022 this feature is not included in any released JDK, OpenJDK 17.0.4 release with this feature is planned for May 2022. + +### NVDA workaround +NVDA 2021.3.1 does not handle widget position properly. Until they fix it we can override DPI awareness in NVDA compatibility settings as shown: + +![NVDA compatibility settings](./images/nvda-compat.png) + diff --git a/tutorials/Accessibility/images/custom-widget.png b/tutorials/Accessibility/images/custom-widget.png new file mode 100644 index 0000000000..860ee2f4c2 Binary files /dev/null and b/tutorials/Accessibility/images/custom-widget.png differ diff --git a/tutorials/Accessibility/images/nvda-compat.png b/tutorials/Accessibility/images/nvda-compat.png new file mode 100644 index 0000000000..1eb4664266 Binary files /dev/null and b/tutorials/Accessibility/images/nvda-compat.png differ