0

How to do that my HUD Window panel (Second window) will be in front of Main Window (first-main Window) in center? Just like a child window to move with the parent window (Main Window).

Main Window is sizable and movable.. so when I orderFront or makeKeyAndOrderFront my HUD Window panel is displaying by coords of screen, but not by Main Window.

Justin Boo
  • 10,132
  • 8
  • 50
  • 71

2 Answers2

4

Solution A: before showing the HUD, set its frame to the appropriate position in the middle. If the user moves the main window, adjust the HUD as well.

Solution B: make the HUD a child window with the [parentWindow addChildWindow:hudWindow ordered: NSWindowAbove]; call.

NSSplendid
  • 1,957
  • 1
  • 13
  • 14
1

NSWindow has the mether -center that will center it on the main screen. And you can use NSWindow's -addChildWindow(NSWindow*)win ordered:NSWindowAbove]; to have it move with the parent window.

Alex Zielenski
  • 3,591
  • 1
  • 26
  • 44
  • Thank You for Your help! "NSWindow has the mether -center" do You mean that this is "Size Inspector" -> Center Horizontally and center Vertically? if I choose this I get warning "Automatic centering of windows unsupported in Xcode versions prior to 4.0". I'm using Xcode 4.2 on Lion. And with addChildWindow it's not working for me.. Thats how I'm doing: In MyClass.h IBOutlet NSWindow *loadingImages; IBOutlet NSWindow *mainWindow; In MyClass.m [mainWindow addChildWindow:loadingImages ordered: NSWindowAbove]; – Justin Boo Nov 15 '11 at 07:26
  • 1
    Don't worry about that warning. It is just for people who are below XCode 4.2. -center will center it both horizontally and vertically. Also, your code is correct you must be doing something else incorrectly. (maybe your outlets aren't set) – Alex Zielenski Nov 15 '11 at 11:22