• 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: controlTextDidChange, backspace possible?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: controlTextDidChange, backspace possible?


  • Subject: Re: controlTextDidChange, backspace possible?
  • From: "M. Uli Kusterer" <email@hidden>
  • Date: Tue, 14 Sep 2004 22:10:11 +0200

At 16:02 Uhr +0000 14.09.2004, Peter Karlsson wrote:
The idea to make a formatter is great, but I don't have that skill. I am just a newbee. But if some of the pros here want to do it I would be very happy. There is a date formatter and a number formatter in IB. I think there should be a third one as well that solves this type of problems once for all.

It shouldn't be too hard. Just subclass NSFormatter. Then look at what methods NSFormatter declares and implement the ones you think you need. I would guess that NSFormatter provides default implementations for all of its methods, so you probably won't have to write anything but what you actually need.From six methods, that leaves:


- (BOOL)isPartialStringValid:(NSString *)partialString newEditingString:(NSString **)newString errorDescription:(NSString **)error;
// Compatibility method. If a subclass overrides this and does not override the new method below, this will be called as before (the new method just calls this one by default). The selection range will always be set to the end of the text with this method if replacement occurs.


- (BOOL)isPartialStringValid:(NSString **)partialStringPtr
		proposedSelectedRange:(NSRangePointer)proposedSelRangePtr
		originalString:(NSString *)origString
		originalSelectedRange:(NSRange)origSelRange
		errorDescription:(NSString **)error;

The comment tells us to use the one at the bottom in favor of the one at the top. So, all you probably need to do is implement the bottom-most method. It gives you all you need: A string to check for validity, what the field contained before this edit, The selection range as it is currently and as it was before the edit. And the errorDescription you can probably ignore.

Should be manageable. Just try it. If it doesn't work, ask here and we can help you along. Most of us probably don't have the time to write the class and get it debugged right now, but we can help you work it out if you do it.
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
References: 
 >Re: controlTextDidChange, backspace possible? (From: "Peter Karlsson" <email@hidden>)

  • Prev by Date: Poor Design? Re: controlTextDidChange, backspace possible?
  • Next by Date: Re: @protected variable access
  • Previous by thread: Re: controlTextDidChange, backspace possible?
  • Next by thread: Re: controlTextDidChange, backspace possible?
  • Index(es):
    • Date
    • Thread