> On Apr 19, 2016, at 11:52 PM, Quincey Morris > <[email protected]> wrote: > > On Apr 19, 2016, at 22:25 , Richard Charles <[email protected]> wrote: >> >> I am not sure where the alert sheet comes from but … > > I just looked this up here: > > > https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CocoaBindings/Concepts/MessageFlow.html > > under the heading "User Updates a Value in the User Interface”. This picture > dates back to OS X 10.5, but it’s still accurate AFAIK — which is an > indication of the last time bindings functionality was … er … improved, or > even changed, really. According to this, the NSFormatter validation happens > very early. (If you ever feel you’ve grasped OS X, this is a good page to > prove you wrong. ;) )
The engineers at Apple that invented and implemented this stuff must have been amazing. > One alternative solution is to use a “captive” NSFormatter. That is, take it > off the text field in IB, and create one in code. Then implement the KVC > validate<Key> method to apply the formatter yourself, and deal with the > formatting failure however you want. Actually I don’t do anything in IB, it is all done programmatically for various reasons. I have a fairly complex NSFormatter subclass. My NSTextField subclass also has some unique functionality. > To do this, you could create a KVO-compliant derived NSString property in > (say) your view or window controller, and bind the naked text field to that > instead. I will need to think about that. > It’s more work than you’ve done (and you have to figure out the quirky > validate<Key> API) but it gives you more control about what you do when the > input is invalid, and what you change the invalid field back to. I mention > this because beeping is only a marginally less crappy UI than the one you’re > trying to avoid. Actually a beep is not all that bad. But then again it depends on how often your computer is beeping. I worked at a place once where there was a room full of engineers all working on Macs. One particular engineer did not like working on a Mac, as a matter of fact he hated Macs. His computer was beeping all the time. He eventually got a PC to work on but the quality of his work never really did improve. I think a great way to learn an app would be for a vendor to provide targeted training videos. Some of these exist on youtube but most of them that I have watched have been created by a third party. No one likes to read a manual anymore and the Help menu has rarely been of help to me when I needed help. So onward and upward, a beep it is! --Richard Charles _______________________________________________ Cocoa-dev mailing list ([email protected]) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [email protected]
