Re: NSFormatter Question: NSTextField should not be left blank
Re: NSFormatter Question: NSTextField should not be left blank
- Subject: Re: NSFormatter Question: NSTextField should not be left blank
- From: Bill Cheeseman <email@hidden>
- Date: Mon, 10 Jun 2002 16:32:51 -0400
on 02-06-10 3:01 PM, Heiko at email@hidden wrote:
>
Is there no way to prevent the user of leaving the NSTextField when he didn't
>
type anything?
I believe the best way to do this is to implement NSControl's
control:textShouldEndEditing: delegate method. Here's an excerpt from my
application. I'll leave it to you to write the sheet or take other action,
perhaps just NSBeep(), when the text field is empty. As you have discovered,
formatters can't catch empty text fields.
- (BOOL)control:(NSControl *)control textShouldEndEditing:(NSText
*)fieldEditor {
if (control == [self speedTextField]) {
if ([[fieldEditor string] isEqualToString:@""]) {
return [self sheetForBlankTextField:control
name:NSLocalizedString(@"Speed Limiter", @"Name of Speed Limiter text
field")];
}
}
return YES; // let other controls resign
}
--
Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com
The AppleScript Sourcebook -
http://www.AppleScriptSourcebook.com
Vermont Recipes -
http://www.stepwise.com/Articles/VermontRecipes
Croquet Club of Vermont -
http://members.valley.net/croquetvermont
_______________________________________________
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.