如何调用NSCell的fieldEditorForView:分配自定义字段编辑器
我有一个 NSTextView,我想将其用作 NSTextField 的字段编辑器。
由于视图中还有其他不使用自定义字段编辑器的 NSTextField,看来我应该使用 NSCell 的方法,
- (NSTextView *)fieldEditorForView:(NSView *)aControlView
但我无法思考如何调用它,但还没有找到任何使用它的示例。
NSCell 的文档说“aControlView”是:
包含需要的单元格的视图 自定义字段编辑器。
我的大脑所说的意思是“这个 NSTextField 所在的视图”,而不是 NSTextField (作为 NSView 的子类)。
NSView *viewTheTextFieldIsIn;
CustomTextView *customTextView subclass of NSTextView (the field editor)
NSTextField *textField
但是:
[[textField cell] fieldEditorForView:customTextView];
对我来说没有任何意义,因为它不是 viewForFieldEditor:
...而是在 NSCell 上。
有人会怜悯我,并消除我的想法吗?
I have an NSTextView, which I want to use as the field editor of an NSTextField.
Since there will be other NSTextFields in the view that do not use a custom field editor, it seems I should use NSCell's method
- (NSTextView *)fieldEditorForView:(NSView *)aControlView
I can't wrap my brain around how to call this, though and have not found any examples of it in use.
NSCell's docs say that 'aControlView' is :
The view containing cells that require
a custom field editor.
Which my brain is saying means 'the view this NSTextField is in', and not the NSTextField (as a subclass of NSView).
NSView *viewTheTextFieldIsIn;
CustomTextView *customTextView subclass of NSTextView (the field editor)
NSTextField *textField
However:
[[textField cell] fieldEditorForView:customTextView];
makes no sense to me because its not viewForFieldEditor:
...but its on NSCell.
Would someone have mercy on me, and un-snarl my thinking?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只是想我会为档案回答这个问题,因为我想我现在明白了,
(睡眠的作用令人惊奇)。
具体方法调用的用法可以是:
通过使用窗口的委托方法,可以将customTextView用作fieldEditor:
其中client可以是textField。
然后,对 textField 上的
fieldEditorForView
的调用将返回该 CustomTextView。Just thought I would answer this for the archive as I think i understand it now,
(amazing what sleep will do).
The specific method call's usage can be:
The customTextView can be used as a fieldEditor by using the window's delegate method:
where client can be the textField.
Then the call to
fieldEditorForView
on the textField will return that CustomTextView.