Page 1 of 1

Start user entry filed with a capital letter? - Solved

Posted: Mon Feb 13, 2017 1:52 am
by DR White
I have looked in the dictionary under text, Capital and keyboard, but
can't find how to Start user entry filed with a capital letter?

Could someone give me a clue?

Also, I would like to be able to have the cursor go to the last character of the text in a user entry field, when I click on it, how?

Thanks,

David

Re: Start user entry filed with a capital letter?

Posted: Mon Feb 13, 2017 6:45 am
by dunbarx
Hi

How is the user interacting? Do they simply type into a field? If so, you might trap the keyDown message. Put this in the field script:

Code: Select all

on keyDown tKey
   if me is "" then
      put toUpper(tKey) into me
      select after text of me
   else pass keyDown
end keyDown
Now can you think of other ways to do the same thing?

Craig Newman

Re: Start user entry filed with a capital letter?

Posted: Wed Feb 15, 2017 7:14 pm
by DR White
Craig,

Your code works great!

Thanks,

David

Re: Start user entry filed with a capital letter? - Solved

Posted: Wed Feb 15, 2017 7:57 pm
by dunbarx
I just reread the whole of your post.

Put this into the field script:

Code: Select all

on selectionChanged
   select after text of me
end selectionChanged
I originally thought that trapping the "openField" message would do the same thing. It does not. Sequence of LC internal workings, I guess...

Craig

Re: Start user entry filed with a capital letter? - Solved

Posted: Wed Feb 15, 2017 10:39 pm
by DR White
Craig,

I really did not describe my objective very well, which was to automatically start the beginning of a user entry field with a capital letter, when the user starts to type in the field.

Your code was just what I needed to get me started.

I ended up with:

On TextChanged
if len(me) = 1 then
put toUpper(me) into me
select after text of me
end if
End TextChanged

Thanks so much,

David

Re: Start user entry filed with a capital letter? - Solved

Posted: Wed Feb 15, 2017 11:32 pm
by dunbarx
Well and good, and you found another message to exploit.

The second post was about sending the insertion point to the end of any existing text. You had mentioned that as well.

Craig

Re: Start user entry filed with a capital letter? - Solved

Posted: Thu Feb 16, 2017 3:00 am
by DR White
Craig,

On you first post, I wondered why you did not mention anything about cursor going to the last character of the text in a user entry field.
But, as I played with your solution to my first issue, I found that "select after text of me" worked well for placing the cursor at the end of text in a field.

Thanks again for all your help,

David