Start user entry filed with a capital letter? - Solved

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Start user entry filed with a capital letter? - Solved

Post by DR White » Mon Feb 13, 2017 1:52 am

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
Last edited by DR White on Wed Feb 15, 2017 7:15 pm, edited 1 time in total.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

Re: Start user entry filed with a capital letter?

Post by dunbarx » Mon Feb 13, 2017 6:45 am

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

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: Start user entry filed with a capital letter?

Post by DR White » Wed Feb 15, 2017 7:14 pm

Craig,

Your code works great!

Thanks,

David

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

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

Post by dunbarx » Wed Feb 15, 2017 7:57 pm

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

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

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

Post by DR White » Wed Feb 15, 2017 10:39 pm

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

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10330
Joined: Wed May 06, 2009 2:28 pm

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

Post by dunbarx » Wed Feb 15, 2017 11:32 pm

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

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

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

Post by DR White » Thu Feb 16, 2017 3:00 am

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

Post Reply