如何调用NSCell的fieldEditorForView:分配自定义字段编辑器

发布于 2024-10-05 16:26:17 字数 746 浏览 0 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

错爱 2024-10-12 16:26:17

只是想我会为档案回答这个问题,因为我想我现在明白了,
(睡眠的作用令人惊奇)。

具体方法调用的用法可以是:

 CustomTextView *customTextView = (CustomTextView *)[[self.textField cell] fieldEditorForView:self.textField];
[customTextView doSomeOtherStuffWithIt];

通过使用窗口的委托方法,可以将customTextView用作fieldEditor:

-(id)windowWillReturnFieldEditor:(NSWindow *)sender toObject:(id)client

其中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:

 CustomTextView *customTextView = (CustomTextView *)[[self.textField cell] fieldEditorForView:self.textField];
[customTextView doSomeOtherStuffWithIt];

The customTextView can be used as a fieldEditor by using the window's delegate method:

-(id)windowWillReturnFieldEditor:(NSWindow *)sender toObject:(id)client

where client can be the textField.

Then the call to fieldEditorForView on the textField will return that CustomTextView.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文