Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Completion in NSTextView

I am looking for a way (or code) to have a completion list close to the one of xcode xcode completion

Do you know how to achieve this?

Thanks and regards,

like image 756
AP. Avatar asked Sep 05 '11 05:09

AP.


1 Answers

Use the

- (NSArray *)textView:(NSTextView *)textView completions:(NSArray *)words forPartialWordRange:(NSRange)charRange indexOfSelectedItem:(NSInteger *)index

method of NSTextViewDelegate. This is called whenever text completion is initiated (either by the user, by pressing Esc or F5, or programmatically, by calling -[NSTextView complete:].

You'll need to do some fancy overriding to make it look like the one in Xcode, however. The stock implementation displays only plain text in the system font.

like image 115
Aderstedt Avatar answered Sep 19 '22 14:09

Aderstedt