NSTextField在附加到NSStatusItem的NSPopover上无效 [英] NSTextField isn't active on NSPopover attached to NSStatusItem

查看:117
本文介绍了NSTextField在附加到NSStatusItem的NSPopover上无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样创建的NSStatusItem:

I have a NSStatusItem created like this:

statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength];
[statusItem setTitle:@"DS"];
[statusItem setHighlightMode:YES];
[statusItem setAction:@selector(StatusClicked:)];
[statusItem setTarget:self]; 

我还有一个带有customview的弹出框.在视图上,我有文本字段: http://d.pr/i/CWbr

I also have a popover with customview. On the view I have textfield: http://d.pr/i/CWbr

我的弹出窗口显示如下:

My popover is shown like this:

- (void)StatusClicked:(id)sender {
    [self.popover showRelativeToRect:[sender bounds] ofView:sender preferredEdge:NSMaxYEdge];
}

从调试器中我了解到senderNSStatusBarButton类的实例.

From a debuger I learned that sender here is an instance of NSStatusBarButton class.

问题在于,当弹出弹出窗口时,我无法在文本字段中键入内容时,它会显示不活动状态: http://d.pr/i/q18U

The problem is that when the popover pops I can't type in textfield, it apears inactive: http://d.pr/i/q18U

该按钮仍在工作.

我认为问题出在我传递给ofView:的视图中.我试图将其更改为这样的窗口控件:

I think that problem is in the view I pass to ofView:. I tried to change it to a control on window like this:

 [self.popover showRelativeToRect:[sender bounds] ofView:self.postText preferredEdge:NSMaxYEdge];

并且文本字段变为活动状态( http://d.pr/i/DmTz ),但是我有不知道为什么会有帮助.

And textfield became active (http://d.pr/i/DmTz) but I have no idea why this helps.

为什么从菜单中弹出时,我的弹出文本框变得不活动? 为什么按钮起作用? 如何激活文本框?

Why does my popover textfield becomes inactive when poped from menu? Why button works? How can I make textfield active?

P. S. 我的应用是Application is agent (UIElement)

P. S. My app is Application is agent (UIElement)

推荐答案

在写完问题后,我认为这可能与关键窗口有关.因此,我搜索了此连接并发现了以下问题:即使设置了可编辑行为,也无法在NSPopover上编辑NSTextField

After writing the question I thought this can be related to key windows. So I searched for this connection and found this question: Not being able to edit NSTextField on NSPopover even though Editable behavior is set

这完美回答了我的问题.似乎是个错误.

This answered my question perfectly. It apears to be a bug.

这篇关于NSTextField在附加到NSStatusItem的NSPopover上无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆