Validation of NSTextField contents
Validation of NSTextField contents
- Subject: Validation of NSTextField contents
- From: Mike Kobb <email@hidden>
- Date: Fri, 9 Jun 2006 14:34:38 -0700
Hi,
I'm new to Cocoa programming (but not to programming), and my
first Cocoa project is a little System Preferences pane. FYI: I have
an "Apply Now" button similar to the one in the Network->TCP/IP pane,
because my pane interacts with a server process that needs to be
restarted when the settings update. I also have an NSTabView with
some controls in each of the two tabs.
Everything is generally working fine, and I'm down to the last
piece of the puzzle, which is to validate the settings that the user
enters into my pane.
I started by implementing the control:isValidObject delegate
method and using it to call NSRunAlertPanel if the value is wrong
(and then return NO from the isValidObject method), and this seems to
work fine if the user enters an invalid value and then tries to tab
out of that text field.
However, if the user clicks to switch to a different tab, the tab
view content for the new tab partially draws, then the modal comes
up, then the tab finishes drawing. Similarly, if the user tries to
unload my prefs pane or quit the System Preferences app, the
validation doesn't happen in time to stop the process.
I'm wondering what the proper way is to handle this. I know that
there are delegate methods for the preferences pane itself as well as
for the tab view that I can implement to prevent the tab from
switching and the panel from unloading, but I guess it's not clear to
me how exactly that should work.
Let's take a for instance: let's say that editing is active in a
field where the user has to specify a number between 1 and 100, and
they have entered 150. They click on the "Show All" button to unload
my pane. What should happen so that I can decide whether my values
are all correct before answering the shouldUnselect delegate method?
I have a second question, regarding modal alerts, but I'll post it
in a second message.
Thanks so much for any insight (or pointers to example code!)
--Mike
_______________________________________________
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