Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Set max chars for Unicode Edit Text control?



On 7/26/04 1:56 AM, Manfred Schubert didst favor us with:

> Am 26.07.2004 um 07:23 schrieb Laurence Harris:
>
>> How exactly do you want to limit the text?
>
> Just limit it to a maximum of characters. Let's say the text field can
> hold 5 characters I want it to beep on the sixth and not add it to the
> text (or beep on paste if I would support paste).
>
>>> I tried Laurence' suggestion installing an
>>> kEventTextInputUnicodeForKeyEvent handler, but it failed for Japanese.
>>> I have to try your suggestion.
>>
>> Failed in what way?
>
> From the event handler I check the string length

I take it this refers to the text in the control.

> and beep and return
> noErr when the maximum is reached, so that the key is swallowed.
> However when I type Japanese the handler is not called for every
> character but only after each "bunch" of Japanese. So if text length is
> let's say 4 which would be enough to hold another character I can type
> a bunch of Japanese and exceed the limit.

Are you testing the length of the input text in the handler or is it
designed around the assumption that it will only get one character at a
time? You should have something like this:

UInt32 dataSize;
OSStatus err = GetEventParameter( inEvent,
kEventParamTextInputSendText, typeUnicodeText, NULL, 0, &dataSize, NULL );

if ( err == noErr && dataSize > 0 )
{
UniCharCount charCount = dataSize / sizeof( UniChar ),


Larry
_______________________________________________
carbon-development mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/carbon-development
Do not post admin requests to the list. They will be ignored.


References: 
 >Re: Set max chars for Unicode Edit Text control? (From: Manfred Schubert <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.