Re: Number Formatter
Re: Number Formatter
- Subject: Re: Number Formatter
- From: Alex Kac <email@hidden>
- Date: Wed, 21 Jan 2009 13:50:28 -0600
If you're on the iPhone, there is no IB formatters. I only mention
that because of your comment about touch input.
On Jan 21, 2009, at 1:21 PM, Brooke Gravitt wrote:
On Wed, Jan 21, 2009 at 12:44 PM, Peter Hudson wrote:
In IB in the Library panel, just below half way down there is a
symbol
on the left hand side which is a dollar sign ( and a calendar symbol
next to it ) which is the number formatter. Click this and drag it
to the text field - and drop it on it. Once the formatter is applied
to the text field there is a small circle to the lower right of the
edge of the text field - with a dollar in it. Click this symbol and
the formatter setup panel will appear in the Attributes Inspector.
Set away !
Hmm. I seem to remember this being in in older versions of IB, but I
am not seeing this in the new one. Unless I am being stupid, which I
probably am.
There is however a slight problem in using formatters for input. If
you set it for numbers only, when the user types in an illegal
character ( something other than a digit ) and tries to tab out of
the
field, they simply can't escape. Likewise if you set a target /
action and they try to press return to complete the entry. There
must
be ways of frigging with the formatter to change this - but I've
never
bothered.
Hmm. This is all touch-input, so I'll see how it goes.
Instead of using a formatter, if I want to collect digits from the
user I simply subclass the NSTextField and override -
(void)textDidChange:(NSNotification *)aNotification. Then every time
the user enters something you can check what they have written and
either allow it or not.
For example to convert input to uppercase I do the following :-
-(void)textDidChange:(NSNotification *)aNotification
{
if( [upperCaseBtn state] == NSOnState )
{
[self setStringValue:[[self stringValue]
uppercaseString]];
}
}
peter
I'm interested in numbers only, so I'll have to figure it out.
Alex Kac - President and Founder
Web Information Solutions, Inc.
"Champions aren't made in the gyms. Champions are made from something
they have deep inside of them - a desire, a dream, a vision. They have
last-minute stamina, they have to be a little faster, they have to
have the skill, and the will. But the will must be stronger than the
skill."
-- Muhammad Ali
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden