开发者

click on the Menu bar item to show a window

开发者 https://www.devze.com 2022-12-14 13:09 出处:网络
Here\'s my code: if ([window isVisible]) { [NSApp activateIgnoringOtherApps:YES]; [window orderOut:nil];

Here's my code:

if ([window isVisible]) {
   [NSApp activateIgnoringOtherApps:YES];
   [window orderOut:nil]; 
   return;
} 
[NSApp activateIgnoringOtherApps:YES];
[window makeKeyAndOrderFront:nil];
return;

but if the user clicks/changes the current window and then 开发者_StackOverflow中文版clicks on menu bar it will close the window. How do I stop that?


Instead of testing whether the window is ordered in (isVisible), test whether it is the active window ([NSApp mainWindow] or [NSApp keyWindow]—details) and whether your application is active ([NSApp isActive]).

0

精彩评论

暂无评论...
验证码 换一张
取 消