Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Output messages on Mac!
This is done using a wrapper for the OS X accessibility API which posts announcement requested notifications. Closes #36.
- Loading branch information
Showing
4 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| #!/bin/sh | ||
| clang -dynamiclib -o reaper_osara.dylib -current_version 1.0 -compatibility_version 1.0 -fvisibility=hidden -undefined dynamic_lookup -stdlib=libc++ -std=c++11 -I ../include -I ../include/WDL -I ../include/WDL/wdl/swell reaper_osara.cpp | ||
| clang++ -dynamiclib -o reaper_osara.dylib -current_version 1.0 -compatibility_version 1.0 -fvisibility=hidden -undefined dynamic_lookup -stdlib=libc++ -std=c++11 -I ../include -I ../include/WDL -I ../include/WDL/wdl/swell reaper_osara.cpp -fobjc-arc -framework Appkit osxa11y.mm |
This file contains 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| #import <AppKit/AppKit.h> | ||
| #include "osxa11y_wrapper.h" | ||
|
|
||
| @interface OSXA11y : NSObject | ||
| - (void)announce:(NSString*)message; | ||
| @end | ||
|
|
||
| @implementation OSXA11y | ||
| namespace NSA11yWrapper { | ||
| struct osxa11yImpl | ||
| { | ||
| OSXA11y* pWrapper; | ||
| }; | ||
|
|
||
| void init() | ||
| { | ||
| impl = new osxa11yImpl; | ||
| impl->pWrapper = [[OSXA11y alloc] init]; | ||
| } | ||
|
|
||
| void osxa11y_announce(const std::string& message) | ||
| { | ||
| NSString* param = [NSString stringWithUTF8String:message.c_str()]; | ||
| [impl->pWrapper announce:param]; | ||
| } | ||
|
|
||
| void destroy() | ||
| { | ||
| if (impl != NULL) | ||
| delete impl; | ||
| } | ||
| } | ||
|
|
||
| - (void)announce:(NSString*)message { | ||
| NSDictionary *announcementInfo = @{NSAccessibilityAnnouncementKey : message, | ||
| NSAccessibilityPriorityKey : @(NSAccessibilityPriorityHigh)}; | ||
|
|
||
| NSAccessibilityPostNotificationWithUserInfo([NSApp mainWindow], NSAccessibilityAnnouncementRequestedNotification, announcementInfo); | ||
| } | ||
| @end |
This file contains 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| #ifndef osxa11y_wrapper_h | ||
| #define osxa11y_wrapper_h | ||
| #include <iostream> | ||
|
|
||
| namespace NSA11yWrapper { | ||
| struct osxa11yImpl; | ||
| static osxa11yImpl* impl; | ||
|
|
||
| void init(); | ||
| void osxa11y_announce(const std::string& param); | ||
| void destroy(); | ||
| } | ||
|
|
||
| #endif |
This file contains 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