Dmitriy
On 24 Oct 2013, at 16:41, Dmitriy Balakirev <[email protected]> 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 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]