【问题标题】:NSTextField isn't active on NSPopover attached to NSStatusItemNSTextField 在附加到 NSStatusItem 的 NSPopover 上不活动
【发布时间】:2013-03-24 11:04:58
【问题描述】:

我有一个这样创建的 NSStatusItem:

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

我也有一个带有自定义视图的弹出窗口。在视图中我有文本字段:http://d.pr/i/CWbr

我的弹出框如下所示:

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

从调试器中我了解到sender 这里是NSStatusBarButton 类的一个实例。

问题是当弹出窗口弹出时我无法在文本字段中输入,它似乎处于非活动状态:http://d.pr/i/q18U

该按钮可以正常工作。

我认为问题出在我传递给ofView: 的视图中。我试图将其更改为窗口上的控件,如下所示:

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

文本字段已激活 (http://d.pr/i/DmTz),但我不知道这有什么帮助。

为什么我的弹出框文本框在从菜单中弹出时变为非活动状态? 为什么按钮有效? 如何激活文本字段?

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

【问题讨论】:

    标签: objective-c xcode menu popover nsstatusbar


    【解决方案1】:

    写完问题后,我认为这可能与关键窗口有关。于是我搜索了这个连接,发现了这个问题:Not being able to edit NSTextField on NSPopover even though Editable behavior is set

    这完美地回答了我的问题。它似乎是一个错误。

    【讨论】:

      猜你喜欢
      • 2012-04-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-17
      • 2012-04-10
      • 1970-01-01
      相关资源
      最近更新 更多