Tab with button

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
DavJans
Posts: 275
Joined: Thu Dec 12, 2013 4:21 pm

Tab with button

Post by DavJans » Mon Jan 20, 2014 8:36 pm

I can't figure this one out. what I have is a inspection form that we fill out and depending on what we are inspecting we end up using N/A alot.
what I want is a button that:

Put "N/A" into the selection
and
select the next field

If i manually hit enter or tab it will do this but I'm not sure how to send an enter or tab code properly
Put cr or Tab is not the answer, already tried that
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här

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

Re: Tab with button

Post by dunbarx » Mon Jan 20, 2014 8:53 pm

Hi.

It depends on how your fields are ordered. So when you say "the next field" we need a way to find which one that is. Perhaps this can be done by field number. Make a few fields on a new card and one button. Put this into the button script.

Code: Select all

on mouseUp
   put the number of the selectedField into currentField
   put "N/A" into the selection
   select the text of fld (currentField + 1)
end mouseUp
Set the cursor into the first field you made, and click...

Now there is a problem with this short script. Can you fix it?

If there is some other way you want to arrange what the "next field" is, we need to talk. Write back if you get stuck.

Craig Newman

DavJans
Posts: 275
Joined: Thu Dec 12, 2013 4:21 pm

Re: Tab with button

Post by DavJans » Mon Jan 20, 2014 9:50 pm

This works! however.... now i have another problem. When using this new button it ignored the closeField script I have in the field.

I fixed it:

Code: Select all

on mouseUp
   put the number of the selectedField into currentField
   put "N/A" into the selection
   send closeField to fld currentField
   select the text of fld (currentField + 1)
end mouseUp
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här

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

Re: Tab with button

Post by dunbarx » Mon Jan 20, 2014 11:28 pm

Right on.

So I guess field layer numbering is OK with your setup?

And sometimes the order of handler execution matters; I think you are right in leaving the "select text" line last in the button handler. It is possible to lose field focus with this sort of thing if it gets more complicated.

But you did not encounter a little problem after clicking the button a few times? Should have...

Craig

DavJans
Posts: 275
Joined: Thu Dec 12, 2013 4:21 pm

Re: Tab with button

Post by DavJans » Tue Jan 21, 2014 12:36 am

I must admit, it took me a while to fix tab order after I had moved about 20 fields around. but I found it in the property inspector under size and position. lucky for me I found that last week so this worked out great.
Since I brought it up and am not 100% sure I guess I could ask. Layer number is what I ended up editing on the fields and made that chronological. My question is, is the number assigned to a field here per card or per stack? And is this the correct way to do it?
"Det bästa stället att hitta en hjälpande hand är i slutet av din egen arm" förutom här

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

Re: Tab with button

Post by dunbarx » Tue Jan 21, 2014 4:13 am

Fields are layer specific to each card.

Background fields may common to each card, and the layer they have depends on when other objects were added to that card.

Note that the number of a field is not the same as the layer that field is on. Do you have this down pat? A mixture of buttons and fields, say, added to a card, will take successive layers. But fields, say, will number themselves only within their class.

Craig

Post Reply