开发者

Allow specific number of NSWindow copies to be visible

I have a button in my application, when you click it it opens a new NSWindow. However, if you keep on clicking it it will open another NSWindow. How can I开发者_如何学Go limit the number of visible windows?


Disable the button. If you have a button that creates a new window, then it should create a new window. If you don't want the user to create a new window, don't let them click the button.

edit if you're dealing with something like a preferences window, then you should probably be using an NSWindowController subclass to control the window. Clicking the button should essentially do (preferencesWindowController is an ivar):

- (void) showPreferences:(id)sender {
  if (preferencesWindowController == nil) {
    preferencesWindowController = [[PreferencesWindowController alloc] init];
  }
  [preferencesWindowController showWindow:sender];
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜