• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: User Interface Validation doesn't work, right?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: User Interface Validation doesn't work, right?


  • Subject: Re: User Interface Validation doesn't work, right?
  • From: Bill Cheeseman <email@hidden>
  • Date: Wed, 1 Jul 2009 19:32:06 -0400

On Jul 1, 2009, at 7:00 PM, Keary Suska wrote:

This has never been true. Right?

No, I would say it is usually true, but not always.

I would like very much to see a project in which it does work. The documentation certainly says it works, but my efforts to make it work suggest that the documentation is wrong. Have you ever seen a project in which it works, or are you just relying on the documentation?


My custom window controller implements the action method for a button, so it is the button's target, and it also implements - validateUserInterfaceItem:, all according to the User Interface Validation document. But my -validateUserInterfaceItem: method is never called.

Implementing the action method isn't sufficient, BTW. The object must also be the current target (i.e. first responder for nil- targeted actions, or designated target). Also note that not all user interface items do this--they must conform to the NSValidatedUserInterfaceItem (or NSUserInterfaceValidations) protocol, which IIRC NSButton does not. In fact, I think only menu items and toolbar items do.

My controller is the target, which according to Apple's documentation, and according to my understanding for many years, means simply that it implements the button's action method. My controller does in fact implement the action method. In addition, my controller is in the responder chain, which is demonstrated by the fact that the action method, which is connected to the First Responder proxy in Interface Builder, executes correctly when I click the button. Also, I declare the controller to conform to the NSUserInterfaceValidations protocol, which it does because it implements the -validateUserInterfaceItem: method. NSButton does conform to the NSValidatedUserInterfaceItem protocol, as its header file confirms, and it does implement the - action: and -target: methods required by that protocol.


So I think you are claiming this works because the documentation says so. I'm saying the documentation is wrong because it doesn't work. I would love to see a project proving me wrong. Can you show me one?

It does work if you've implemented a menu item that calls the same action method, because the menu item validation protocol works as advertised. That is, it falls back on -validateUserInterfaceItem: if you don't implement -validateMenuItem. Toolbar item validation also works, because, like menu item validation, it is wired to do so. So don't send me any projects showing that menu items and toolbar items work correctly. My complaint is that this technique doesn't work for user interface items other than menu items and toolbar items, and that the documentation claiming it does work is wrong.

--

Bill Cheeseman
email@hidden
_______________________________________________

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


  • Follow-Ups:
    • Re: User Interface Validation doesn't work, right?
      • From: Andy Lee <email@hidden>
  • Prev by Date: Determining OS at Runtime
  • Next by Date: Re: User interface validation doesn't work, right?
  • Previous by thread: Re: User interface validation doesn't work, right?
  • Next by thread: Re: User Interface Validation doesn't work, right?
  • Index(es):
    • Date
    • Thread