diff --git a/glfw/cocoa_window.m b/glfw/cocoa_window.m index e07197e1c..d3d2f1a53 100644 --- a/glfw/cocoa_window.m +++ b/glfw/cocoa_window.m @@ -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 // }}}