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
.
Try this if it helps, for perform auto completion you will need to call complete:
in the text fields field editor by using below delegate method:-
- (void)controlTextDidChange:(NSNotification *)notification {
if( autoComplete ){
return;
} else {
autoComplete = YES;
[[[notification userInfo] objectForKey:@"NSFieldEditor"] complete:nil];
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With