From: Stefan Csomor Date: Wed, 13 Apr 2011 09:22:17 +0000 (+0000) Subject: preparing for completions support X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/00ba1af984e6771a2cfd3da8c292e7031c21d242 preparing for completions support git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67438 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/osx/cocoa/srchctrl.mm b/src/osx/cocoa/srchctrl.mm index c9b722d727..e665167688 100644 --- a/src/osx/cocoa/srchctrl.mm +++ b/src/osx/cocoa/srchctrl.mm @@ -61,6 +61,30 @@ impl->controlTextDidChange(); } +- (NSArray *)control:(NSControl *)control textView:(NSTextView *)textView completions:(NSArray *)words + forPartialWordRange:(NSRange)charRange indexOfSelectedItem:(int*)index +{ + NSMutableArray* matches = NULL; + NSString* partialString; + + partialString = [[textView string] substringWithRange:charRange]; + matches = [NSMutableArray array]; + + wxTextWidgetImpl* impl = (wxTextWidgetImpl* ) wxWidgetImpl::FindFromWXWidget( self ); + wxArrayString completions; + + // adapt to whatever strategy we have for getting the strings + // impl->GetTextEntry()->GetCompletions(wxCFStringRef::AsString(partialString), completions); + + for (size_t i = 0; i < completions.GetCount(); ++i ) + [matches addObject: wxCFStringRef(completions[i]).AsNSString()]; + + // [matches sortUsingSelector:@selector(compare:)]; + + + return matches; +} + @end // ============================================================================ diff --git a/src/osx/cocoa/textctrl.mm b/src/osx/cocoa/textctrl.mm index 738482a841..364c3993b2 100644 --- a/src/osx/cocoa/textctrl.mm +++ b/src/osx/cocoa/textctrl.mm @@ -289,6 +289,29 @@ protected : impl->controlTextDidChange(); } +- (NSArray *)control:(NSControl *)control textView:(NSTextView *)textView completions:(NSArray *)words + forPartialWordRange:(NSRange)charRange indexOfSelectedItem:(int*)index +{ + NSMutableArray* matches = NULL; + NSString* partialString; + + partialString = [[textView string] substringWithRange:charRange]; + matches = [NSMutableArray array]; + + wxTextWidgetImpl* impl = (wxTextWidgetImpl* ) wxWidgetImpl::FindFromWXWidget( self ); + wxArrayString completions; + + // adapt to whatever strategy we have for getting the strings + // impl->GetTextEntry()->GetCompletions(wxCFStringRef::AsString(partialString), completions); + + for (size_t i = 0; i < completions.GetCount(); ++i ) + [matches addObject: wxCFStringRef(completions[i]).AsNSString()]; + + // [matches sortUsingSelector:@selector(compare:)]; + + return matches; +} + - (BOOL)control:(NSControl*)control textView:(NSTextView*)textView doCommandBySelector:(SEL)commandSelector { wxUnusedVar(textView);