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/25/04 11:53 PM, Scott Thompson didst favor us with:

>> Oh, that's unfortunate. I thought there must have been an easy way for
>> the common task.
>>
>> Isn't there any event that is send every time the text changes? I
>> could then simply shorten it to the max length and it would cover all
>> cases.

Such an event almost made it into Panther, but was nixed at the last moment.
It was even in one of the headers for a while. I was bummed. But I expect to
see it in Tiger.

>> I'm not getting kEventControlValueFieldChanged and
>> kEventControlTitleChanged.

Correct. The text in an Edit Unicode Text control is neither the value
(which is the same value as any other control--an integer), nor it's title
(despite the misleading labeling in IB). This is why you don't set the text
with SetControlValue() or SetControlTitle().
>
> Unfortunately, your best bet for the existing operating systems is to
> take advantage of two separate features of the control that can
> tag-team to help you out.
>
> First, you might want to provide your control with a key filter using
> the kControlKeyFilterTag with SetControlData. The Key Filter tag will
> allow you to access the contents of the control as each key is pressed.
> You have the ability to accept, or reject, keystrokes using that
> filter.

Unfortunately, key filters are not Unicode saavy. That's why I suggested
using a kEventTextInputUnicodeForKeyEvent handler, which is the recommended
approach.

> Next, you will probably want a validation proc (using
> kControlEditTextValidationProcTag). This procedure can be used to
> validate the contents of the field when data is pasted into the
> control.

Note that a validation proc isn't called until after the text has been
pasted. At best this means your application would be allowing a paste which
has no effect, which as user experiences go is less than ideal. Better to
disable the Paste command if you don't want to allow pasting of what's on
the Clipboard.

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: Scott Thompson <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.