I programmatically call complete:
to call NSTextView autocompletion delegate method:
- (NSArray *)control:(NSControl *)control textView:(NSTextView *)textView completions:(NSArray *)words forPartialWordRange:(NSRange)charRange indexOfSelectedItem:(NSInteger *)index
I have 2 tables, one is in the main sheet, and the other one in the popup window. The popup window is modally opened from the sheet.
Both tables have the column with the same subclass of NSTextView. Both tables have as delegate the same file owner, however the delegate method is called only for the table in the main sheet.
The strange thing is that all other delegate methods are correctly called from the table in the 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:
The tables are cell-based NSTableView
. The column is made by NSTextFieldCell
that I've subclassed. The code below is from the subclassed NSTextFieldCell
.
The method returns another subclass, named CBAutocompleteTextField, this time inheriting from NSTextView, which is the text editor inside the cell.
- (NSTextView *)fieldEditorForView:(NSView *)aControlView
{
return [[[CBAutocompleteTextField alloc] init] autorelease];
}
So in the end, the class invoking complete:
is a subclass of NSTextView
.
NSTextView
but alsoNSTextField
. Are you using a custom field editor? Is the table a view-based table? In that case, I guess you have an actualNSTextField
, in which case what matter is the text field's delegate, not the table's delegate. If you're using anNSCell
-based table view, then you would haveNSTextFieldCell
s rather thanNSTextField
s and the table's delegate would be relevant. – Ken Thomases