Re: Forcing a cell's field editor to send control:textShouldEndEditing: when leaving a cell
Re: Forcing a cell's field editor to send control:textShouldEndEditing: when leaving a cell
- Subject: Re: Forcing a cell's field editor to send control:textShouldEndEditing: when leaving a cell
- From: Alastair Houghton <email@hidden>
- Date: Tue, 11 Aug 2009 22:33:04 +0100
On 11 Aug 2009, at 19:53, Chris Arnaiz wrote:
I've been struggling to control the behavior of a NSTableView while
editing cells.
[snip]
My goal is to prevent the user from leaving a cell (mouse click, tab
key, enter key, etc) before they provide a valid value for that entry.
Hi Chris,
Rather than trying to use -control:textShouldEndEditing:, have you
tried using an NSFormatter subclass? That's the way I would normally
implement validation for user input, and it's possible that it *might*
solve your problem.
Also, two other points worth considering:
1. Can you fill in a reasonable default value? I'm sure you've
thought about this already, but a very Mac-like thing to do is to go
to considerable lengths to work out what to do by default, so that
your user doesn't have to.
2. Is preventing the user from leaving the field really the best
option? Might it be better to merely ignore empty entries, or even to
remove them automatically at some point? Again, I'm sure you've
considered this already, but it's an important point. Sometimes there
are better options.
Kind regards,
Alastair.
--
http://alastairs-place.net
_______________________________________________
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