PDA

View Full Version : Actions and windows




silentnosie
May 27, 2009, 09:04 PM
For the time being I'm dealing with two separate windows(one is a panel) in Xcode3.

I have one button on the panel window that sends text to a text field on window one. I would like to have the panel close and a new panel open when I push the button, while sending text still.

My controller.h file I have:
#import <Cocoa/Cocoa.h>

@interface Domaintest : NSObject {
IBOutlet id display;
IBOutlet NSPanel* Domain01;
}
- (IBAction)click:(id)sender;
@end
I named the file Domain01 in IB under Identity tab on the Name field not the Class one or anywhere else

For my controller.m file i have:

#import "Domaintest.h"

@implementation Domaintest
- (IBAction)click:(id)sender {
[display setStringValue:@"Domain Test"];
[Domain01 Close];

}
@end


The button is sending the text just fine but it's not closing the window. When I build I get two warning (yellow color) that NSPanel may bot respond to '-Close'.

Anybody have any suggestion on how to fix or do this another way?



larkost
May 28, 2009, 10:48 AM
The behavior you want from NSWindow is '-close'. Objective-C (like C) is case-sensitive, so '-close' and '-Close' are different things.

silentnosie
May 28, 2009, 12:42 PM
Okay I changed Close to close, it's sending the text still, but the panel window refuses to close.

silentnosie
May 29, 2009, 01:12 PM
cool beans man, got it to work. I started at test project and forgot to rename the panel to Domain01.

What would I use to get another window opened

#import "tester.h"

@implementation tester
- (IBAction)click:(id)sender {
[display setStringValue:@"Domain Test"];
[Domain01 close];
[Domain02 open];
}
@end

sorry been a few years since I did any type of programing and some stuff I just don't remember or never tried

silentnosie
May 29, 2009, 01:23 PM
lol well this came back to me also right after I posted.

Got it working with

#import "tester.h"

@implementation tester
- (IBAction)click:(id)sender {
[display setStringValue:@"Domain Test"];
[Domain01 close];
[Domain02 orderFront:self];
}
@end

man I never thought I would forget this crap, but it's coming back slowly. Thanks again for your help man.