NSSearchField - 显示带有结果的 NSMenu
我正在尝试弄清楚如何在搜索字段下方显示搜索结果。我想原因是我的程序从未收到消息
-(NSArray *)control:(NSControl *)control textView:(NSTextView *)textView completions:(NSArray *)words forPartialWordRange:(NSRange)charRange indexOfSelectedItem:(int*)index;
所以我永远无法返回任何结果。
但是,我确实收到
- (void)controlTextDidChange:(NSNotification *)obj;
- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)commandSelector;
任何可能的原因是什么?我确实设置了代表。
I'm trying to figure out how to display results of search below my search field. I suppose the cause is that my program never receives the message
-(NSArray *)control:(NSControl *)control textView:(NSTextView *)textView completions:(NSArray *)words forPartialWordRange:(NSRange)charRange indexOfSelectedItem:(int*)index;
So I can never return any results.
However, I do receive
- (void)controlTextDidChange:(NSNotification *)obj;
- (BOOL)control:(NSControl *)control textView:(NSTextView *)textView doCommandBySelector:(SEL)commandSelector;
Any chances what the cause may be? I did set the delegate.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除非在文本字段的字段编辑器上的某个时刻调用
complete
,否则您的委托将不会收到completions:
消息。在controlTextDidChange:
中,您可以执行以下操作:毫无疑问,您必须使其变得更加复杂(当您的委托返回完成列表时,将调用
controlTextDidChange:
再次,创建一个无限循环),但这应该可以帮助您开始。Your delegate won't receive the
completions:
message unlesscomplete
gets called at some point on the field editor of the text field. IncontrolTextDidChange:
you can do this:You will, without a doubt, have to make this more sophisticated (when your delegate returns the list of completions,
controlTextDidChange:
will be called again, creating an infinite loop), but that should get you started.