Page 1 of 1
Moving cursor focus
Posted: Thu Jun 20, 2013 8:40 pm
by sandybassett
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.
Re: Moving cursor focus
Posted: Thu Jun 20, 2013 9:09 pm
by snm
Try "select" in openCard handler
Marek
Re: Moving cursor focus
Posted: Thu Jun 20, 2013 9:12 pm
by dunbarx
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
Re: Moving cursor focus
Posted: Thu Jun 20, 2013 10:03 pm
by sandybassett
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.
Re: Moving cursor focus
Posted: Thu Jun 20, 2013 10:15 pm
by jmburnod
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
Re: Moving cursor focus
Posted: Thu Jun 20, 2013 11:11 pm
by dunbarx
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
Re: Moving cursor focus
Posted: Fri Jun 21, 2013 12:51 am
by sandybassett
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.
Re: Moving cursor focus
Posted: Fri Jun 21, 2013 2:17 am
by sandybassett
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.
Re: Moving cursor focus
Posted: Fri Jun 21, 2013 2:52 am
by dunbarx
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
Re: Moving cursor focus
Posted: Fri Jun 21, 2013 8:26 am
by jacque
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.
Re: Moving cursor focus
Posted: Fri Jun 21, 2013 11:41 pm
by sandybassett
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?
Re: Moving cursor focus
Posted: Mon Jun 24, 2013 7:06 am
by dunbarx
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
Re: Moving cursor focus
Posted: Mon Jun 24, 2013 9:27 am
by Dixie
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