4

I have a HUD window that has some labels on it, and I want this to show when the user presses a button. I know this is simple, but I can't get it to show again unless I restart my program.

Sincerely,

Kevin

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
lab12
  • 6,400
  • 21
  • 68
  • 106

2 Answers2

12

To hide hudWindow:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
    [hudWindow orderOut:nil]; // to hide it
}

Then on button press:

- (IBAction)showWindow:(id)sender {
    [hudWindow makeKeyAndOrderFront:nil]; // to show it
}
Scott Greenlay
  • 587
  • 1
  • 7
  • 13
  • 3
    You don't need to hide the window programmatically on launch, you should just uncheck the "Visible at launch" checkbox in Interface Builder. – Rob Keniger Sep 06 '09 at 02:01
  • for this should I make an outlet? and the should the type be NSPanel? – lab12 Oct 01 '09 at 20:47
8

In IB, go to the window's attributes inspector and make sure that "Released when closed" isn't checked.

NSResponder
  • 16,861
  • 7
  • 32
  • 46
  • I needed this to fix my HUD window, if I closed the window and then showed it again, I got a window where no clicks would register. When I unticked "Released when closed" my window was interactive again and back to normal, so thanks! – Dan Harper Apr 02 '11 at 13:00