mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-10-23 21:52:18 +00:00
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 _glfwPlatformUpdateIMEState(_GLFWwindow *w, const GLFWIMEUpdateEvent *ev) {
|
|||
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…
Add table
Add a link
Reference in a new issue