Add macOS VoiceOver accessibility helpers to WxWidget#150
Merged
Conversation
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::.
47636ae to
1825962
Compare
… 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).
Owner
|
can you help to fix the ci failures? |
Contributor
Author
|
@AllenDang Done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
set_accessibility_label(label: &str)to theWxWidgettrait (macOS only): setsNSAccessibilityLabelon the underlyingNSViewso 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__/MSWDisableCompositedpattern for platform-specific window methods.Motivation
On macOS, form dialogs typically pair a
StaticTextlabel with awxChoice(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
set_accessibility_labelcompiles and links#[cfg(target_os = "macos")]and the.mmfile is excluded from non-macOS builds)