Re: User interface validation doesn't work, right?
Re: User interface validation doesn't work, right?
- Subject: Re: User interface validation doesn't work, right?
- From: Andy Lee <email@hidden>
- Date: Thu, 02 Jul 2009 11:47:54 -0400
On Thursday, July 02, 2009, at 03:48AM, "Bill Cheeseman" <email@hidden> wrote:
>I'm not "assuming" that it works with all user controls. The document
>I quoted from says it does, explicitly and in detail, without
>qualification.
This is why in my Radar I suggested the "validated item" terminology to indicate there is a special class of user interface items. It seems obvious to me to follow the tradition of English terms matching Objective-C names very naturally: an NSTableView is a table view, an NSTextField is a text field, and an NSValidatedUserInterfaceItem should be a validated (user interface) item.
>The protocol documents say, as you noted, that they "work together" to
>implement user interface validation. They go on to state that "The
>NSMenuItem and NSToolbar Item classes take advantage of these
>protocols." Grammatically, that sentence is written as if these are
>simply two examples of classes that do so; it does not state that they
>are the ONLY classes that do so.
And it doesn't point out that they don't *always* do so (depending on the autoenablesItems and autovalidates flags). I'm not saying that doc should repeat the details of menu enabling and toolbar validation, but I do think it would be worth adding links to the "Enabling Menu Items" and "Validating Toolbar Items" sections to provide some hint that there is a larger story. I just submitted bottom-of-the-page feedback to this effect.
>In trying to pin down whether buttons also do so, I looked at the
>NSButton Class Reference document and found that it expressly conforms
>to the NSUserInterfaceValidations protocol.
This is true but irrelevant. NSUserInterfaceValidations is for the object that validates, not the one that is validated. What this means is that if you have a menu item with an NSButton as its target, the button gets to decide whether the menu item is enabled. But we don't know what logic it uses to do this, because NSButton's implementation of validateUserInterfaceItem: is not documented. I would love to hazard a guess, but one doesn't come to mind offhand.
>I did find it confusing when I read the NSMenuItem and NSToolbarItem
>Class Reference documents, which say that they conform to the other
>protocol, the NSValidatedUserInterface protocol. But this tends to
>suggest that NSButton will work, too, since NSControl, from which
>NSButton inherits, also conforms to the NSValidatedUserInterface
>protocol.
Well, it implements the methods, but since NSValidatedUserInterfaceItem is a formal protocol, I would say NSButton doesn't conform to it in the sense of [NSButton conformsToProtocol:@protocol(NSValidatedUserInterfaceItem)]. I agree it's very easy to be confused, because the implementation of item validation might or might not care whether the validated item conforms formally to the protocol, and this seems a natural thing for a button to do.
Since the docs in question are relatively small, very fundamental, and IMO potentially very confusing, it seems to me this is low-hanging fruit for Apple's doc team and worth addressing sooner rather than later.
--Andy
_______________________________________________
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