RE: Poor Design? Re: controlTextDidChange, backspace possible? [SOLVED]
RE: Poor Design? Re: controlTextDidChange, backspace possible? [SOLVED]
- Subject: RE: Poor Design? Re: controlTextDidChange, backspace possible? [SOLVED]
- From: "Peter Karlsson" <email@hidden>
- Date: Wed, 15 Sep 2004 06:32:44 +0000
Dear list!
I have a nice formatter now that lets me do exactly what I want, limit the
input in my textfield to 32 characters. Just subclass NSFormatter. It can't
be much simpler then this:
- (BOOL)isPartialStringValid:(NSString *)partialString
newEditingString:(NSString **)newString errorDescription:(NSString **)error
{
if ([partialString length] > 32)
{
return(NO);
}
else
{
return(YES);
}
}
This is VERY flexible. Just check for whatever you need to do, and return
YES or NO.
A VERY big thank you to Daniel Todd Currie for learning me how to do this.
A better way is to have this limit in a field in IB, exactly as Daniel said.
But that is not up to me, it's up to the developers of OS X.
Best regards Peter
From: Daniel Todd Currie <email@hidden>
To: email@hidden
Subject: Poor Design? Re: controlTextDidChange, backspace possible?
Date: Tue, 14 Sep 2004 12:54:49 -0700
I've read your previous message to Uli, and still I don't understand why
this would be poor design... I think it makes perfect sense to encapsulate
field length limits in the field itself. Neither the controller nor the
model should have any interest in this value, so why burden them with it?
I personally like to have a sort of built-in data handler for my more
complicated UI elements. The element handles formatting and
interpretation, and only provides the controller what it needs.
Another example of this is an NSPopUpButton subclass I used in two of my
apps. When the user clicks on the popup button, it polls CoreAudio for a
list of available audio devices, populates the menu, THEN presents the user
with the menu. This is a simple way of handling the issue of a dynamic
device list at the last possible instant before it needs to be presented to
the user. Furthermore, the controller and the model don't care in the
slightest what devices are available, only what device is selected.
-- DTC
On 2004 Sep 14, at 10:25, Ondra Cada wrote:
On 14.9.2004, at 17:52, Peter Karlsson wrote:
Why don't have a field in IB where I just type 32 for length, period!
For it would be a *pretty bad* design, perhaps? See my previous message
for Uli.
---
Ondra Äada
OCSoftware: email@hidden http://www.ocs.cz
private email@hidden http://www.ocs.cz/oc
_______________________________________________
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
_______________________________________________
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
_________________________________________________________________
Add photos to your e-mail with MSN 8. Get 2 months FREE*.
http://join.msn.com/?page=features/featuredemail
_______________________________________________
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