How Can I Implement VoiceOver Actions for Mac Correctly?
How Can I Implement VoiceOver Actions for Mac Correctly?
- Subject: How Can I Implement VoiceOver Actions for Mac Correctly?
- From: Chi Kim <email@hidden>
- Date: Sun, 24 Feb 2019 02:03:11 +0000
- Thread-topic: How Can I Implement VoiceOver Actions for Mac Correctly?
Hi All,
I have a button that responds to various mouse clicks (regular click,
right click, control+click, option+click, command+click...) to show
different popup menus.
Since it would be annoying for VoiceOver users to use actual physical
mouse, I would like to map those to different VoiceOver actions.
However, I'm not getting the results I expected. Could someone help me
to understand better what I'm missing?
Here is what I discovered so far.
1. If I subclass NSButton and override the following functions, they
work fine. Except there's one odd thing. If I press vo+command+space to
bring up the list of available actions, VoiceOver says Action 1 instead
of Show Menu.
@override func accessibilityPerformPress() -> Bool {
print("Pressed!")
return true
}
override func accessibilityPerformShowAlternateUI() -> Bool {
print("Show Alternate UI")
return true
}
override func accessibilityPerformShowMenu() -> Bool {
print("Show Menu")
return true
}
2. In the same NSButton subclass, if I also override
accessibilityCustomActions function, "Do Something" never comes up in
the list of available actions when I press vo+command+space.
override func accessibilityCustomActions() ->
[NSAccessibilityCustomAction]? {
let custom = NSAccessibilityCustomAction(name: "Do Something",
target: self, selector: #selector(doSomething))
return [custom]
}
@objc func doSomething() -> Bool {
print("Done something.")
return true
}
3. If I subclass NSView instead of NSButton, and override the same
functions from #1, everything works fine. Unlike first case, even the
action from accessibilityPerformShowMenu correctly says Show Menu
instead of Action 1.
4. in the same NSView subclass, if I override accessibilityCustomActions
along with accessibilityPerformPress, accessibilityPerformShowMenu, or
accessibilityPerformShowAlternateUI, "Do Something" doesn't come up in
the action list.
5. However, "Do Something" does come up in the action list if I just
override accessibilityCustomActions by itself without
accessibilityPerformPress, accessibilityPerformShowMenu, and
accessibilityPerformShowAlternateUI.
I tried creating another action with the name "Press" that does the same
thing when pressing vo+space, and including in the return value of
accessibilityCustomActions. But then Vo+space did not trigger the
action. Instead, I had to press vo+command+space, and then select "Press".
I guess the action just has the name "Press", but it's not actually
connected to vo+space. I'm not sure how I can actually make that
particular custom action to respond to vo+space.
I would appreciate if someone could help me to implement
accessibilityCustomActions as well as accessibilityPerformPress,
accessibilityPerformShowMenu, and accessibilityPerformShowAlternateUI
together into NSButton.
Thanks so much!
Chi
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Accessibility-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden