Maneuver within a grid of fields
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Maneuver within a grid of fields
I have been playing with a crossword puzzle app. I have #rows x #columns sets of boxes in which to enter the letters. These are groups containing a grc (to color in blank spaces), an index (numbering the across or down beginnings) and a field for the Letter. Livecode will naturally allow the player to tab through the letter field of the boxes/grps using the TAB key, but I would like to also use the arrow keys. An "on arrowkey the key" type handler works, except I do not know how to change the focus from the former letter field to the new one found using arrow keys. I am confused about "focus" and how to enter data in a field without using the mouse or the tab key.
-
- VIP Livecode Opensource Backer
- Posts: 9663
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Maneuver within a grid of fields
Hi.
Do you have an "arrowKey" handler in, say, the card script? Are your individual fields named in such a way as to allow a natural progression through them? For example, "f1,f2,f3,..."
There are many ways to do what you want. Sometimes a bit of prep as per the above makes that medicine go down much easier.
Craig
Do you have an "arrowKey" handler in, say, the card script? Are your individual fields named in such a way as to allow a natural progression through them? For example, "f1,f2,f3,..."
There are many ways to do what you want. Sometimes a bit of prep as per the above makes that medicine go down much easier.
Craig
-
- VIP Livecode Opensource Backer
- Posts: 9663
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Maneuver within a grid of fields
So if you have three fields named "f1", "f2". and "f3", and the cursor is in fld "f1", and this is in the card script:
Focus, and the cursor, will appear in fld "f2".
What happens when the last field is in focus?
Right. You have to manage this. Do you know how?
Craig
Code: Select all
on arrowkey tKey
put the last char of the short name of the focusedObject into currentField
if tKey = "right" then select text of fld ("f" & currentField + 1)
end arrowkey
What happens when the last field is in focus?
Right. You have to manage this. Do you know how?
Craig