Implement macOS accessibility protocol to provide selected text
Allow "Speak selection" (Option+Esc) to work properly.
This commit is contained in:
parent
0d116e6ef0
commit
74714f942a
1 changed files with 30 additions and 0 deletions
|
|
@ -1540,6 +1540,36 @@ - (void)doCommandBySelector:(SEL)selector
|
|||
debug_key("\n\tdoCommandBySelector: (%s)\n", [NSStringFromSelector(selector) UTF8String]);
|
||||
}
|
||||
|
||||
- (BOOL)isAccessibilityElement
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)isAccessibilitySelectorAllowed:(SEL)selector
|
||||
{
|
||||
if (selector == @selector(accessibilityRole) || selector == @selector(accessibilitySelectedText)) return YES;
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (NSAccessibilityRole)accessibilityRole
|
||||
{
|
||||
return NSAccessibilityTextAreaRole;
|
||||
}
|
||||
|
||||
- (NSString *)accessibilitySelectedText
|
||||
{
|
||||
if (_glfw.callbacks.get_current_selection) {
|
||||
NSString *text = nil;
|
||||
const char *s = _glfw.callbacks.get_current_selection();
|
||||
if (s) {
|
||||
text = [NSString stringWithUTF8String:s];
|
||||
free((void*) s);
|
||||
return text;
|
||||
}
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
// }}}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue