Moving cursor focus

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
sandybassett
Posts: 35
Joined: Fri May 31, 2013 7:44 pm

Moving cursor focus

Post by sandybassett » Thu Jun 20, 2013 8:40 pm

I move from card 1 to card 2 with a go to next card command. But when card 2 opens the cursor isn't in any field. If I click Tab it goes to the first field OK, but how do I make it go there automatically when the card opens? Thanks for the help.

snm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 253
Joined: Fri Dec 09, 2011 11:17 am

Re: Moving cursor focus

Post by snm » Thu Jun 20, 2013 9:09 pm

Try "select" in openCard handler

Marek

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

Re: Moving cursor focus

Post by dunbarx » Thu Jun 20, 2013 9:12 pm

Hi.

In an opencard handler:

select text of fld "yourField"

This can be in the stack script if you want this behavior every time you navigate. You might also select before or after that text, depending...

Craig Newman

sandybassett
Posts: 35
Joined: Fri May 31, 2013 7:44 pm

Re: Moving cursor focus

Post by sandybassett » Thu Jun 20, 2013 10:03 pm

Thanks guys; I tried both and several other ways, including 'put Tab into fieldname' but nothing works. What I want is just for the user to be able to see the blinking cursor when the card displays so as to guide him to enter data into that first field first. Any other ideas, I hope. Thanks for the help.

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Moving cursor focus

Post by jmburnod » Thu Jun 20, 2013 10:15 pm

Hi sandybasset,

As Craig said you can use an opencard handler in the stack like this

Code: Select all

on opencard
   select after text of fld 1
end opencard
I think that should be the last line of the opencard script

King regards
Jean-Marc
https://alternatic.ch

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

Re: Moving cursor focus

Post by dunbarx » Thu Jun 20, 2013 11:11 pm

Jean-Marc probably fixed your problem with my offering. Is it so?

What he means is that if you had any code after the 'select" line, perhaps the insertion point was lost in subsequent machinations. Such things can be fragile. Make sure the line is either the only line or the last line.

Craig

sandybassett
Posts: 35
Joined: Fri May 31, 2013 7:44 pm

Re: Moving cursor focus

Post by sandybassett » Fri Jun 21, 2013 12:51 am

Thanks Jean-Marc and Craig! It works, for some reason instead of being in the left-most position of the field, the cursor appears in about the 6th or 7th position,as if it were tabbed over. When you hit the backspace or left arrow, it moves directly over to the first position. Strange action, what do you suppose could make it behave like that? Thanks for your help.

sandybassett
Posts: 35
Joined: Fri May 31, 2013 7:44 pm

Re: Moving cursor focus

Post by sandybassett » Fri Jun 21, 2013 2:17 am

I have manipulated text with toUpper (for state abbrev) and with toLower (for email address), but how do you capitalize the first letter of each word and lowercase the rest of the word. In some other systems that's called TitleCase or MixedCase, but I haven't found it here. How do you accomplish that in LiveCode? Thanks for your help.

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

Re: Moving cursor focus

Post by dunbarx » Fri Jun 21, 2013 2:52 am

SandyBasset. Sandy?

Firstly, didn't you say you had loaded tabs into that field during your travails?

Second, this Titlecase thing is something you simply must work out for yourself. It will be an easy and fun project. You already know the function "toUpper" in the dictionary. In fact, that function needs a bit of massaging to be useful in this effort. Write back if you need help.

I challenge you to do the same thing without using that function at all. Use the ASCII values of characters instead. In other words, what is the difference between an "A" and an "a"? What is the pun embedded in that last sentence?

Get going.

Craig

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Moving cursor focus

Post by jacque » Fri Jun 21, 2013 8:26 am

I know you already solved it, but for future reference, if your field has lowest layer on the card the text will be selected automatically when the card opens. The field must be editable for that to happen, but it sounds like that's the case.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

sandybassett
Posts: 35
Joined: Fri May 31, 2013 7:44 pm

Re: Moving cursor focus

Post by sandybassett » Fri Jun 21, 2013 11:41 pm

Thanks guys (& gals) for the help. This is what finally works:
on opencard
put empty into field "aptname"
select text of field "aptname"
end opencard
Also I had the field labels in the first layers before the fields, so I reversed that and now it works fine.
Craig, I think you are telling me that there is no TitleCase function in LiveCode and I had better resurrect an ancient coding technique into LC language to roll my own. Maybe something like-separate chunks by space, put each chunk toLower, get 1st char of each chunk & put toUpper, merge chunks back together. If that's right, since I would be using this on most all input fields, I should make it a function and put it somewhere? so as to have it available for including in every stack I create? N'est pas?

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

Re: Moving cursor focus

Post by dunbarx » Mon Jun 24, 2013 7:06 am

Absolutement.

You need to extract the first char of each word, find out if it is a candidate for making uppercase, do that if so, and reform the word.

Making a library script of some kind is spot on, and the gadget should live as a function. Sounds like you can do this without any problems.

Craig

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Moving cursor focus

Post by Dixie » Mon Jun 24, 2013 9:27 am

sandybassett..

I thought that this problem had already been sorted for you in the posting 'title case'

Code: Select all

 on mouseUp
       put toLower( fld 1) into fld 1
       repeat with count = 1 to the number of words of fld 1
          put toUpper( char 1 of word count of fld 1) into char 1 of word count of fld 1
       end repeat
    end mouseUp

Post Reply