Objective C - How to put a close button in window? -
I'm having trouble with putting a close button in my window in Objective-C, I've created a button, but I do not know What method do I need to stop the window, I have done this:
- (zero) awakeFromNib {// Create a button NSRect frame = NSMakeRect (350, 10, 100, 50); NSButton * btn = [[NSButton alloc] initWithFrame: frame]; [BTN SETBUTTON TYPE: NSMantrypush Inbutton]; [BTN set bezel style: NSRattbeizle style]; [BTN SETITAL: @ "OFF"]; [BTN Set Target: Self]; [BTN set action: @sillector (close window)]; [Adsview view: BTN] See; } - {zero} closeWindow {} I do not know what to put in closed window method
You can close the current window by using something along these lines:
NSWindow * window = [[NSAPC sharing application] key [Window] ; [close window]; However, it does not actively emulate a user to close a window, because it does not call representative methods, nor exposes a close button You may want to use it instead:
NSWindow * window = [[NSAPCirmation shared application] keywindows]; [Close window display: sender]; In that case, maybe you want to pass your button as the sender you can get to simplify the button object in your closeWindow method Are there.
Comments
Post a Comment