A question about disabling the Save button was just asked on this list a few days ago. The thread is archived here: <http://www.mail- archive.com/cocoa-dev@lists.apple.com/msg38421.html>. Google is your friend...

steve


On Jun 29, 2009, at 6:45 AM, Michael Domino wrote:

I use an NSSavePanel to select a file, enter and confirm a password, encrypt it and save a copy with a new extension. There is an accessory view for
entering and confirming a password. I would like the OK button to be
disabled while there is no file selection, and if the password/confirm
password fields are empty and/or don’t match. I use NSNotificationCenter to
observe the text fields to check whenever the user enters text and
enable/disable the OK button. This all nearly works, the only problem is that when you select a file, the OK button is enabled and I have not been able to find a hook or delegate method that will allow me to override this behavior. I tried observing for changes to _nameField, to see if maybe I
could set the enabled state for the button there, but my method is not
called even though the delegate is set.

What about finding the NSButton view in the dialog window (search for the view title “OK”), replacing it with my own subclass of NSButton to override
setEnable to include the additional criteria?

The other thing is that I’m referencing the _okButton and _nameField outlets in NSSavePanel that do not have accessors, so I get the warning about that
being a hard error in the future, which makes me nervous.

Has anyone needed to solve this problem, and if so how did you do it?
_______________________________________________

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