Hello!
I'm new to programming. I been reading a lot and practicing but I'm still in the learning phase.
This is basically a Cocoa question (not iOS), I don't know if I should post this question here, if not please let me know a Cocoa Forum that I could go to.
Basically I have 1 main window, when I click a Button there a second window opens. I got that to work but I'm unable to close the first window.
Here's the code that I have that it works to open the second window:
bflagcontroller is a class that I made that controls the xib file for the second window.
One thing that I tried (I tried several solutions!) was to instead of closing, just to reopen the first window so when I click on a button on the first window the second window opens and the first window reopens too, that works! So I said I should be able to replace the "showWindow" command...? is that what you call it? Well, I thought I should be able to replace the showWindow with something like "hideWindow" but that didn't work.
Here is what I tried:
This works but instead of "showWindow" I think I should be able to use something like "hideWindow" (for the main menu xib)
My header file just in case is:
Thanks for the help guys! Hope you can help me or point me in the right direction!
----------
I fixed it!
I added [self close] at the beginning and it worked...
So, how do you call this:
this is a Method ? an Object?
Thanks!
I'm new to programming. I been reading a lot and practicing but I'm still in the learning phase.
This is basically a Cocoa question (not iOS), I don't know if I should post this question here, if not please let me know a Cocoa Forum that I could go to.
Basically I have 1 main window, when I click a Button there a second window opens. I got that to work but I'm unable to close the first window.
Here's the code that I have that it works to open the second window:
Code:
- (IBAction)showBflag:(id)sender {
if (!bflagControl) {
bflagControl = [[ bflagController alloc] initWithWindowNibName:@"bflag"];
}
[bflagControl showWindow:self];
}
One thing that I tried (I tried several solutions!) was to instead of closing, just to reopen the first window so when I click on a button on the first window the second window opens and the first window reopens too, that works! So I said I should be able to replace the "showWindow" command...? is that what you call it? Well, I thought I should be able to replace the showWindow with something like "hideWindow" but that didn't work.
Here is what I tried:
Code:
- (IBAction)showBflag:(id)sender {
if (!bflagControl) {
bflagControl = [[ bflagController alloc] initWithWindowNibName:@"bflag"];
menuControl = [[ menuController alloc] initWithWindowNibName:@"MainMenu"];
}
[bflagControl showWindow:self];
[menuControl showWindow:self];
}
This works but instead of "showWindow" I think I should be able to use something like "hideWindow" (for the main menu xib)
My header file just in case is:
Code:
#import <Cocoa/Cocoa.h>
@class bflagController;
@interface menuController : NSWindowController {
@private
bflagController *bflagControl;
}
- (IBAction)showBflag:(id)sender;
@end
Thanks for the help guys! Hope you can help me or point me in the right direction!
----------
I fixed it!
I added [self close] at the beginning and it worked...
So, how do you call this:
Code:
- (IBAction)showBflag:(id)sender {
[self close];
if (!bflagControl) {
bflagControl = [[ bflagController alloc] initWithWindowNibName:@"bflag"];
}
[bflagControl showWindow:self];
}
this is a Method ? an Object?
Thanks!