Skip to content

Commit

Permalink
Post find feedback accessibility announcements
Browse files Browse the repository at this point in the history
  • Loading branch information
sorbits committed Apr 1, 2014
1 parent c3088da commit 5f94f46
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Frameworks/OakTextView/src/OakTextView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,12 @@ + (id)findServerWithTextView:(OakTextView*)aTextView operation:(find_operation_t
- (NSString*)findString { return [[OakPasteboard pasteboardWithName:NSFindPboard] current].string; }
- (NSString*)replaceString { return [[OakPasteboard pasteboardWithName:OakReplacePboard] current].string; }

- (void)showToolTip:(NSString*)aToolTip
{
OakShowToolTip(aToolTip, [self.textView positionForWindowUnderCaret]);
NSAccessibilityPostNotificationWithUserInfo(self.textView, NSAccessibilityAnnouncementRequestedNotification, @{ NSAccessibilityAnnouncementKey : aToolTip });
}

- (void)didFind:(NSUInteger)aNumber occurrencesOf:(NSString*)aFindString atPosition:(text::pos_t const&)aPosition wrapped:(BOOL)didWrap
{
NSString* format = nil;
Expand All @@ -533,7 +539,7 @@ - (void)didFind:(NSUInteger)aNumber occurrencesOf:(NSString*)aFindString atPosit

NSString* classifier = (self.findOptions & find::regular_expression) ? @"matches for" : @"occurrences of";
if(format)
OakShowToolTip([NSString stringWithFormat:format, classifier, aFindString, aNumber], [self.textView positionForWindowUnderCaret]);
[self showToolTip:[NSString stringWithFormat:format, classifier, aFindString, aNumber]];
}

- (void)didReplace:(NSUInteger)aNumber occurrencesOf:(NSString*)aFindString with:(NSString*)aReplacementString
Expand All @@ -543,7 +549,7 @@ - (void)didReplace:(NSUInteger)aNumber occurrencesOf:(NSString*)aFindString with
{ @"Nothing replaced (no matches for “%@”).", @"Replaced one match of “%@”.", @"Replaced %2$ld matches of “%@”." }
};
NSString* format = formatStrings[(self.findOptions & find::regular_expression) ? 1 : 0][aNumber > 2 ? 2 : aNumber];
OakShowToolTip([NSString stringWithFormat:format, aFindString, aNumber], [self.textView positionForWindowUnderCaret]);
[self showToolTip:[NSString stringWithFormat:format, aFindString, aNumber]];
}
@end

Expand Down

0 comments on commit 5f94f46

Please sign in to comment.