Re: Cocoa-dev Digest, Vol 6, Issue 124
Re: Cocoa-dev Digest, Vol 6, Issue 124
- Subject: Re: Cocoa-dev Digest, Vol 6, Issue 124
- From: Brooke Gravitt <email@hidden>
- Date: Wed, 21 Jan 2009 14:21:47 -0500
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.
_______________________________________________
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