Live regions in a desktop application?

I'm developing a desktop application and need the equivalent of a live region to notify visually impaired users of changes on the screen.

The documentation only talks about them in the context of a web page - does this feature work for a desktop applications as well?

Accepted Reply

VoiceOver can be notified about changes in your UI by sending a NSAccessibility.Notification.

Consider using .announcementRequested to announce relevant UI changes to the user.

Links

Replies

VoiceOver can be notified about changes in your UI by sending a NSAccessibility.Notification.

Consider using .announcementRequested to announce relevant UI changes to the user.

Links

Well that looks like just what I need. Thanks! I'll dig into it.

I'm not having any luck in getting it to announce any updates. What am I doing wrong? Using Big Sur with a Qt application. My view seems to be valid, it is the application's main window and comes out to be QNSView: 0x7f9f299bec10; QCocoaWindow(0x7f9f299beb00, window=QWidgetWindow(0x7f9f299be5c0, name="main_windowWindow")).

Code is:

NSView* view = reinterpret_cast<NSView*>(mudlet::self()->effectiveWinId());
if (!view) {
    qDebug() << "no view found";
} else {
    qDebug() << view;
}

NSString* msg = @"Hello World!";
NSDictionary *announcementInfo = @{
    NSAccessibilityAnnouncementKey : msg,
    NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh),
};
NSAccessibilityPostNotificationWithUserInfo(view, NSAccessibilityAnnouncementRequestedNotification, announcementInfo);

Ah, got it to work - just needed

NSString* msg = @"Hello World!";
NSDictionary *announcementInfo = @{
    NSAccessibilityAnnouncementKey : msg,
    NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh),
};
NSAccessibilityPostNotificationWithUserInfo([NSApp mainWindow], NSAccessibilityAnnouncementRequestedNotification, announcementInfo);

Thanks a lot for your help - this improvement made it to the latest update of Mudlet, an open-source MUD client, which is now accessible to visually impaired folks.