【发布时间】:2011-10-05 01:39:21
【问题描述】:
我有一个自定义的 NSButton,我实际上是在一个 NSStatusItem 中。单击 NSButton 时,它会启动我的窗口。再次单击 NSButton 时,窗口应关闭。
如果窗口是打开的,它看起来好像 NSButton 停止响应(或不接收)点击事件!以下是相关代码:
[statusItem setView:myCustomButton];
[myCustomButton setAction:@selector(showWindow:)];
- (void)showWindow:(id)sender {
if(!myWindowController) {
myWindowController = [[MyWindowController alloc] initWithWindowNibName:@"MyWindow"];
}
[myWindowController showWindow:statusItem];
[myWindowController.window orderFront:nil];
}
我在做一些疯狂的事情吗?如果我在上面设置了断点,第一次单击按钮时会命中,但再次单击按钮时不会命中。
【问题讨论】:
标签: objective-c cocoa