Skip to content

Add macOS VoiceOver accessibility helpers to WxWidget#150

Merged
AllenDang merged 7 commits into
AllenDang:mainfrom
trypsynth:macos-accessibility-label
Jun 27, 2026
Merged

Add macOS VoiceOver accessibility helpers to WxWidget#150
AllenDang merged 7 commits into
AllenDang:mainfrom
trypsynth:macos-accessibility-label

Conversation

@trypsynth

@trypsynth trypsynth commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds set_accessibility_label(label: &str) to the WxWidget trait (macOS only): sets NSAccessibilityLabel on the underlying NSView so VoiceOver announces the label as part of the control — e.g. "Language, English, pop up button" — rather than as a separate cursor stop.

Implemented in a new window_osx.mm (Objective-C++) compiled only on macOS, following the existing #ifdef __WXMSW__ / MSWDisableComposited pattern for platform-specific window methods.

Motivation

On macOS, form dialogs typically pair a StaticText label with a wxChoice (NSPopUpButton). Without this, VoiceOver navigates them as two separate elements. Native macOS convention is for the control to announce its own label inline, so the user hears "Language, English, pop up button" in one stop rather than navigating past a "Language:" text and then a separate popup. This PR makes that labeling possible from wxDragon while leaving the static text visible in the VoiceOver cursor order.

Test plan

  • Build on macOS and confirm set_accessibility_label compiles and links
  • Verify VoiceOver announces a labeled popup button as "Label, Value, pop up button" in a single cursor stop
  • Confirm no regressions on Windows and Linux (the method is #[cfg(target_os = "macos")] and the .mm file is excluded from non-macOS builds)

trypsynth added 3 commits June 7, 2026 12:25
Two new macOS-only methods on the WxWidget trait:

- set_accessibility_label(&self, label: &str): sets NSAccessibility label
  so VoiceOver announces "Label, Value, role" as a single cursor stop
  instead of navigating a separate StaticText and control.

- hide_from_accessibility(&self): calls setAccessibilityElement:NO so
  the window is skipped by VoiceOver. Intended for StaticText labels
  whose text has been moved to a nearby control via set_accessibility_label.

Implemented in a new window_osx.mm (Objective-C++) file compiled only
on macOS. Header declarations are guarded with #ifdef __WXOSX__, mirroring
the existing #ifdef __WXMSW__ pattern for MSWDisableComposited.
- Add enable_language(OBJCXX) in the macOS platform block so CMake
  knows how to compile .mm files (fixes CMAKE_OBJCXX_COMPILE_OBJECT error)
- Replace setAccessibilityElement:NO with setAccessibilityHidden:YES —
  the former does not exist on NSView; accessibilityHidden is the correct
  NSAccessibility protocol property for hiding from assistive technologies
bindgen never defines __WXOSX__ (a wxWidgets internal macro), so the
#ifdef __WXOSX__ block in wxd_window_base.h is invisible to it. Match
the existing pattern used for wxd_Window_MSWDisableComposited: declare
the functions in a cfg-gated unsafe extern "C" block in window.rs and
call them directly rather than routing through ffi::.
@trypsynth trypsynth force-pushed the macos-accessibility-label branch from 47636ae to 1825962 Compare June 7, 2026 18:25
trypsynth added 3 commits June 7, 2026 12:36
… path

wxd_App_ActivateMac was declared private in the extern "C" block, causing
E0603 when app.rs tried to import it. Also added cmake cache parsing to
add the iconv library directory to the linker search path, fixing link
failures when cmake was configured against a non-standard libiconv
(e.g. MacPorts /opt/local/lib).
@AllenDang

Copy link
Copy Markdown
Owner

can you help to fix the ci failures?

@trypsynth

Copy link
Copy Markdown
Contributor Author

@AllenDang Done

@AllenDang AllenDang merged commit 39775f3 into AllenDang:main Jun 27, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants