Re: controlTextDidChange, backspace possible?
Re: controlTextDidChange, backspace possible?
- Subject: Re: controlTextDidChange, backspace possible?
- From: "Peter Karlsson" <email@hidden>
- Date: Tue, 14 Sep 2004 16:02:33 +0000
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.
Peter
From: "M. Uli Kusterer" <email@hidden>
To: "Peter Karlsson" <email@hidden>, email@hidden
Subject: Re: controlTextDidChange, backspace possible?
Date: Tue, 14 Sep 2004 17:07:34 +0200
At 14:00 Uhr +0000 14.09.2004, Peter Karlsson wrote:
If I have the cursor in the middle of the string the last character of the
string will dissapear for every new character I type.
Yes, that's exactly what your code does, as it doesn't take into account
the selection.
My idea is to make a backspace so the latest character will not be typed
if the string is already 32 characters in length. Is this possible to do,
or is there better solutions?
Have you looked at NSFormatter? It looks like writing an NSFormatter of
your own will let you do just what you want.
The point is, I do not want anything to happen at all if I type and the
string is already 32 characters in length. So I must find a way to delete
the latest character typed regardless of the position in the string.
If NSFormatter (which would be reusable and looks like the "recommended
way") doesn't let you do what you want, another option might be to replace
the field editor in your window with one where you've overridden the
keyDown: method. Then you could check that there. Or switch to an
NSTextView subclass instead of an NSTextField.
But NSFormatter sounds like it will be a lot less painful in the long
run. And I'm sure lots of people here would be pleased if you put up such a
formatter for download somewhere. Length-limiting text entry fields is a
common enough problem that I don't get why there isn't a solution built in
already.
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
_______________________________________________
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