mirror of
https://github.com/jlengrand/compose-multiplatform.git
synced 2026-03-10 08:11:20 +00:00
Add docs about desktop a11y (#1775)
This commit is contained in:
committed by
GitHub
parent
03d98ae908
commit
d822283c4b
61
tutorials/Accessibility/README.md
Normal file
61
tutorials/Accessibility/README.md
Normal file
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||

|
||||
|
||||
# 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.
|
||||
18
tutorials/Accessibility/Windows.md
Normal file
18
tutorials/Accessibility/Windows.md
Normal file
@@ -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:
|
||||
|
||||

|
||||
|
||||
BIN
tutorials/Accessibility/images/custom-widget.png
Normal file
BIN
tutorials/Accessibility/images/custom-widget.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 332 KiB |
BIN
tutorials/Accessibility/images/nvda-compat.png
Normal file
BIN
tutorials/Accessibility/images/nvda-compat.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 103 KiB |
Reference in New Issue
Block a user