簡體   English   中英

NSTextField在附加到NSStatusItem的NSPopover上無效

[英]NSTextField isn't active on NSPopover attached to NSStatusItem

我有一個NSStatusItem創建如下:

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

我也有一個帶有customview的彈出窗口。 在視圖上,我有文本字段: http : //d.pr/i/CWbr

我的彈出窗口顯示如下:

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

NSStatusBarButton sender我了解到senderNSStatusBarButton類的實例。

問題是,當彈出彈出窗口時,我無法在文本字段中鍵入內容,它會顯示不活動狀態: http ://d.pr/i/q18U

該按鈕雖然起作用。

我認為問題出在我傳遞給ofView:的視圖中。 我試圖將其更改為這樣的窗口控件:

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

文本字段變為活動狀態( http://d.pr/i/DmTz ),但我不知道為什么這會有所幫助。

從菜單彈出時,為什么我的彈出文本框變得不活動? 為什么按鈕起作用? 如何激活文本框?

PS我的應用是Application is agent (UIElement)

寫下問題后,我認為這可能與關鍵窗口有關。 因此,我搜索了此連接並發現了以下問題: 即使設置了可編輯行為,也無法在NSPopover上編輯NSTextField

這完全回答了我的問題。 它似乎是一個錯誤。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM