Sorry for the delay I’m working on this thanks for the help! :-)
> On 25 Mar 2016, at 12:55 PM, dangerwillrobinsondan...@gmail.com wrote: > > > What Ken is saying is use an NSFormatter > It really should have been named something like NSValidator or inherited from > something like that to make it clear that it's for that. > It allows you to alter the input, accept it as is or reject it and you should > present a sheet (or some other means) with some helpful information on why if > rejected. > > It's the right solution. > It also means you can visually show the corrected format when the content is > reliably adjustable to an accepted form. > Even then, it's worth considering displaying information about the change so > that users can still reconsider their input before committing to something > but convenient if they're ok with the proposed reformat. > > Sent from my iPhone > >> On Mar 25, 2016, at 12:47 PM, Ken Thomases <k...@codeweavers.com> wrote: >> >>> On Mar 24, 2016, at 9:29 PM, Rick C. <rickcort...@gmail.com> wrote: >>> >>> I have an NSPanel with 2 NSTextFields and my controller is the delegate of >>> the panel. I want to override the paste behavior of the 2 text fields so >>> that the user doesn’t paste unnecessary spaces and other characters into >>> these fields. >> >> Is pasting really so special? Should the user be able to simply type such >> "unnecessary spaces and other characters" in the fields? Or do you want to >> prohibit that, too? >> >> Probably the easiest approach is to create a custom subclass of NSFormatter >> and assign an instance of that formatter to each text field. The formatter >> would implement >> -isPartialStringValid:proposedSelectedRange:originalString:originalSelectedRange:errorDescription: >> to validate and even adjust the string as it's being edited, regardless of >> the manner of the edit operation (typing, pasting, etc.). >> >> Regards, >> Ken >> >> >> _______________________________________________ >> >> 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: >> https://lists.apple.com/mailman/options/cocoa-dev/dangerwillrobinsondanger%40gmail.com >> >> This email sent to dangerwillrobinsondan...@gmail.com _______________________________________________ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com