Re: NSButton question
Re: NSButton question
- Subject: Re: NSButton question
- From: "Gary B." <email@hidden>
- Date: Fri, 9 Aug 2002 09:22:53 -0700
On Friday, August 9, 2002, at 07:00 AM, Lorenzo Thurman wrote:
I set the initial string value using IB,
not using awakeFromNib. I'll try it that way and see what happens.
Thanks
Or try:
if([[myTextField stringValue]isEqualToString:@"Hello Cocoa World!"]){
--- On Thu 08/08, Howard Griffith wrote:
From: Howard Griffith [mailto: email@hidden]
To: email@hidden
Cc: email@hidden
Date: Thu, 08 Aug 2002 15:18:29 -0700
Subject: Re: NSButton question
Lorenzo,
Just off hand, do you ever set TextField to begin with ?? If you don't
initially set the contents of the Textfield the first place your
initial
button press sets it to "Hello Cocoa World!" if I am reading
your included
source correctly.
You might want to try inserting this info the awakefromnib:
[myTextField setStringValue:@"Hello Cocoa World!"];
This will give it an initial value so the first time you press the
button
the If statement in your changeText will work correctly.
Regards,
Howard Griffith
Mac Hobbyist
On 8/8/02 1:50 PM, "Lorenzo Thurman"
wrote:
--- On Thu 08/08, The MACed wrote:
From: The MACed [mailto: email@hidden]
To: email@hidden
Date: Thu, 08 Aug 2002 09:10:15 -0700
Subject: Re: NSButton question
Mind posting some codes?
Like your action method of the button.
Here's my action method:
- (IBAction)changeText:(id)sender
{
if([myTextField stringValue] == @"Hello Cocoa World!")
[myTextField setStringValue:@"Hello Aqua World!"];
else
[myTextField setStringValue:@"Hello Cocoa World!"];
}
Nothing special, just change the text field's label. Since my first
message, I
tried using awakeFromNib like this:
@implementation MyController
- (IBAction)changeText:(id)sender
{
NSString *tmp;
tmp = currentText;
currentText = [myTextField stringValue];
[myTextField setStringValue:newText];
currentText = newText;
newText = tmp;
}
-(void)awakeFromNib{
currentText = @"Hello Cocoa World!";
newText = @"Hello Aqua World!";
}
@end
This works just fine, but I'd like to know why it does not work
properly the
first time?
Thanks
------------------------------------------------
Join Excite! - http://www.excite.com
The most personalized portal on the Web!
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
--
Test
------------------------------------------------
Join Excite! - http://www.excite.com
The most personalized portal on the Web!
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.