• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSFormatter Question: NSTextField should not be left blank
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >NSFormatter Question: NSTextField should not be left blank (From: Heiko <email@hidden>)

  • Prev by Date: Re: About the accessibility stuff...
  • Next by Date: Re: NSMutableString Replace All
  • Previous by thread: NSFormatter Question: NSTextField should not be left blank
  • Next by thread: DoubleClick in a NSTableView
  • Index(es):
    • Date
    • Thread