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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to