Desktop Accessibility Announcer (JNA) 🧭
A JVM-only helper that provides a Compose Desktop equivalent of
LocalAccessibilityManager.announceForAccessibility() using JNA.
Modules 🧩
accessibility: core API with JNA, no Compose dependency.
accessibilitycompose: Compose-only helpers (CompositionLocal).
demo-compose: Compose Desktop demo using the CompositionLocal.
demo-swing: Swing demo without Compose.
Gradle (Kotlin DSL) 🚀
dependencies {
implementation("io.github.kdroidfilter:accessibility-jvm:<version>")
implementation("io.github.kdroidfilter:accessibility-compose-jvm:<version>")
}
API 🧪
import io.github.kdroidfilter.accessibility.AnnouncementPriority
import io.github.kdroidfilter.accessibility.DesktopAccessibilityManager
DesktopAccessibilityManager.announceForAccessibility(
"Error: Your changes could not be saved.",
AnnouncementPriority.ASSERTIVE,
)
In Compose, use the accessibilitycompose module and the CompositionLocal:
import io.github.kdroidfilter.accessibility.compose.LocalDesktopAccessibilityManager
val accessibility = LocalDesktopAccessibilityManager.current
accessibility.announceForAccessibility("Error: Invalid email address.")
In Swing (no Compose dependency):
import io.github.kdroidfilter.accessibility.AnnouncementPriority
import io.github.kdroidfilter.accessibility.DesktopAccessibilityManager
DesktopAccessibilityManager.announceForAccessibility(
"Saved successfully.",
AnnouncementPriority.POLITE,
)
Demos 🎬
- Compose demo:
./gradlew :demo-compose:run
- Swing demo:
./gradlew :demo-swing:run
Behavior by platform 🧭
- macOS: Uses
NSAccessibilityPostNotificationWithUserInfo with
NSAccessibilityAnnouncementRequestedNotification.
- Windows: Uses the NVDA/JAWS controller APIs when available.
The API returns true when a native announcement request was successfully
submitted. It returns false if the platform doesn't support the request or
if the native call fails.
Usage notes 📝
- Announcements are most reliable when your app window is in the foreground.
- On macOS, VoiceOver must be enabled.
- On Windows, a screen reader (NVDA/JAWS) must be running.
- Enable
allowDesktopAccessibilityManagerLogging to see library logs.
AnnouncementPriority.ASSERTIVE is for urgent messages (errors, blockers).
It may interrupt or flush current speech output on supported screen readers.
Manual test checklist ✅
macOS (VoiceOver) 🍎:
- Enable VoiceOver (System Settings -> Accessibility -> VoiceOver).
- Run the desktop demo app and focus its window.
- Click the "Announce error" button.
- Confirm VoiceOver speaks the error message.
Windows (NVDA/JAWS) 🪟:
- Start NVDA or JAWS.
- Run the desktop demo app and focus its window.
- Click the "Announce error" button.
- Confirm the screen reader speaks the error message.