I programmatically call complete: to invoke the NSTextView autocompletion delegate method:
- (NSArray *)control:(NSControl *)control textView:(NSTextView *)textView completions:(NSArray *)words forPartialWordRange:(NSRange)charRange indexOfSelectedItem:(NSInteger *)index
I have two tables, one located on the main sheet, and the other in a popup window. A popup window opens from the sheet.
Both tables have a column with the same subclass of NSTextView. Both tables have a delegate of the same file owner, however, the delegate method is called only for the table on the main sheet.
It is strange that all other delegate methods are correctly called from a table in a popup window:
- (BOOL)control:(NSControl *)control textShouldEndEditing:(NSText *)fieldEditor - (BOOL)control:(NSControl *)control isValidObject:(id)object - (BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
UPDATE
About the NSTableView structure:
Tables are based on NSTableView cells. The column is made by NSTextFieldCell , which I have subclassed. Below is the code from a subclass of NSTextFieldCell .
The method returns another subclass called CBAutocompleteTextField, this time inheriting from NSTextView, which is a text editor inside the cell.
- (NSTextView *)fieldEditorForView:(NSView *)aControlView { return [[[CBAutocompleteTextField alloc] init] autorelease]; }
Thus, the class calling complete: is a subclass of NSTextView .
source share