• 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: Fri, 3 Jul 2009 04:20:59 -0400

On Jul 2, 2009, at 8:38 PM, Quincey Morris wrote:

It remains totally mysterious what's going to cause individual validatable interface items to trigger their own validation. Perhaps there's no automatic general mechanism at all, and each interface item class has to solve the problem for itself

I would summarize it like this:

In the case of menu items and toolbar items, you have to implement - validateMenuItem: or -validateToolbarItem:, or their fallback - validateUserInterfaceItem:, yourself. In your implementation, you decide which items require validation by testing which action the current item sends (or, rarely, what tag it has). If you implement one of these -validate... methods, it is called automatically by the - update or -validateVisibleItems mechanisms you described.

In the case of buttons, you likewise have to implement - validateUserInterfaceItem: yourself. But that isn't enough, because Cocoa does not call it automatically just because you implemented it. A generic solution is to implement the -windowDidUpdate: delegate method in your window controller, and in it loop through all the subviews in your window's contentView. In each iteration of the loop, call your -validateUserInterfaceItem: method, testing first to make sure the item implements -action and -tag and -setEnabled: (or just test whether it's a button, since all buttons do). If efficiency becomes a problem, take steps to reduce the frequency with which - validatedUserInterfaceItem: is called (every time the window updates -- that is, once every time through the run loop -- may be overkill for many validation scenarios).

--

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: Quincey Morris <email@hidden>
References: 
 >Re: User interface validation doesn't work, right? (From: Andy Lee <email@hidden>)
 >Re: User interface validation doesn't work, right? (From: Quincey Morris <email@hidden>)
 >Re: User interface validation doesn't work, right? (From: Quincey Morris <email@hidden>)

  • Prev by Date: Re: Replace -[NSKeyedUnarchiver unarchiveObjectWithData:] so it doesn't crash on corrupt archive
  • Next by Date: Re: screen lock events?
  • 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