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?



> The reason I mentioned that is that I know there are multiple ways for
> users
> to enter text, more than just typing and pasting. I don't know all the
> details about how all of the work, so I'm reluctant to assume how all
> of the
> interact with a key filter. If someone at Apple wants to clarify that
> and
> alleviate my concerns, that would be cool.

You don't need someone from Apple to help you out. That's part of what
the Carbon-Dev list is all about.

Apart from the fact that the Key Filter proc doesn't tell you how your
keystrokes fit into the current unicode sequence, another problem with
key filters is that user can also enter text through the inline input
window and that window doesn't have any knowledge of what the current
text entry field's environment is. In that case the Key Filter will
not see individual keystrokes that are destined for the inline input
window and the key filter will not be able to prevent the user from
entering whatever text they may care to enter. In this case, a user
using the inline input window can type a long sentence that consists of
many more characters than 5 and the key filter will be none the wiser
until the user accepts the inline input.

That is why you have to pair the key filter with the validation proc.
The Validation proc will be called before the field accepts the text
and the validation proc can, as it's name implies, make sure that the
contents of the field are valid before the key focus leaves the
control.

> This depends on the nature of the data being pasted and the situation.
> If I
> attempt a Paste into a text field, most applications will disable the
> Paste
> command if the data on the Clipboard isn't text, for example. They
> don't
> enable the Paste command and then respond to an attempt to paste by
> posting
> an alert that there's no text to paste. I know this isn't exactly the
> same
> situation, but it's not altogether different either.

Pasting something that isn't text into a text field is a nonsensical
operation and the paste item should be disabled. Pasting text into a
text field, makes sense regardless of the restrictions placed on the
text field's contents.

The situation would be more akin to disabling the paste command for a
password field simply because you can't see the text that you paste in,
or disallowing the user to paste text into a field that can only
contain a number simply because the text on the clipboard MIGHT have a
non-numeric string in it.

> I don't know anything about the application, of course, but if I
> copied a
> string of 10 characters to the Clipboard, 99% of the time I wouldn't
> want
> only one or two of them pasted.

I agree. You certainly wouldn't want the computer to ignore half of
your text without telling you why. You might want to see a dialog that
says "The <field you are entering text> box should not contain more
than 5 characters. Your response will be truncated to fit" (or
something more user friendly which conveys the same message). That way
you have a good idea about how the computer uses the information you
paste into that field.

> If I'm trying to paste 10 characters into a
> text field which only allows five, then either I don't understand that
> it
> only allows five, or the text on the Clipboard isn't what I thought it
> was.

Exactly. That is why, when you attempt to put an invalid value in to
the text field, the Text Validation is there to help the programmer
tell you that it's invalid and explain to you why your entry was
rejected. ;-)

If you continue to paste more characters into the field after you've
been warned about it... well... that' s an issue for the user and a
therapist.

> This is a judgement call, but as a user, I see no significant
> advantage to
> implementing "partial-pasting" code, and it certainly isn't standard.
> For
> example, I have some text fields in my application into which you can
> enter
> type and creator codes. If you copied four characters to the Clipboard
> and
> tried to paste them after three existing characters in one of those
> fields,
> it wouldn't make any sense to offer to do a partial paste. It might
> make
> sense for this field in your application, but it's not an approach I'd
> recommend I general. Just my $0.02.

The advantage is that the user gets a consistent behavior for all Text
entry fields, not just those that happen to take more than a certain
number of characters.

I fail to see how allowing the paste and then warning the user that the
field has too many characters is non-standard. The validation of text
entered into computers, followed by a warning when that text contains
unexpected data, has a long an cherished history in computing. The
field's validation proc was put into place for just such an
eventuality. The practice is standard enough that Cocoa provides
NSFormatters for similar purposes.

From my perspective, it makes no sense to prevent the user from pasting
text into a text entry field with no explanation as to why the paste
command is disabled. However, if that's what makes sense for you in
your own code... :-)

FWIW, I copy and paste four character codes most every day with a
frequency that would probably alarm you. Interface Builder and XCode
are happy to exchange the codes and copy and paste makes it much easier
for me to ensure that I don't fat-finger the codes when trying to keep
them in sync. Of course IB is more than happy to take more characters
into the field than strictly make sense which is a less than ideal
situation as well.

Now if only IB would give me some way to export those codes en-masse
into a header file with my own identifiers... But I digress :-)

--
Macintosh Software Engineering Consulting Services
Visit my resume at <http://homepage.mac.com/easco/RSTResume.html>

[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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: Laurence Harris <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.