Re: NSTextField, maximum string length, bindings and NSFormatter
Re: NSTextField, maximum string length, bindings and NSFormatter
- Subject: Re: NSTextField, maximum string length, bindings and NSFormatter
- From: "email@hidden" <email@hidden>
- Date: Thu, 24 Oct 2013 17:07:09 +0100
Dmitriy
On 24 Oct 2013, at 16:41, Dmitriy Balakirev <email@hidden> wrote:
> For limiting text in NSTextField this works well: (_limit == 5, 30, etc.)
>
> - (BOOL)isPartialStringValid:(NSString *__autoreleasing *)partialStringPtr
> proposedSelectedRange:(NSRangePointer)proposedSelRangePtr
> originalString:(NSString *)origString
> originalSelectedRange:(NSRange)origSelRange
> errorDescription:(NSString *__autoreleasing *)error {
>
> NSString *partialStr = *partialStringPtr;
> if ([partialStr length]) {
> if ([partialStr length] <= _limit) {
> *partialStringPtr = [partialStr uppercaseString];
> return NO;
> }
> *partialStringPtr = [NSString stringWithString:origString];
> *proposedSelRangePtr = NSMakeRange(origSelRange.location, origSelRange.length);
> return NO;
> } else {
> return YES;
> }
> }
>
This sort of illustrates my point.
IMHO this does not work well (certainly not when compared to a WPF TextBox).
I think:
1. Pasting is not handled adequately (sufficient text should be pasted in up to the maxLength).
2. If a range of characters is selected then the selected characters should be removed and then sufficient text should be pasted in up to the maxLength.
Jonathan
_______________________________________________
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