move through lines of two fields

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
francof
Posts: 237
Joined: Fri Apr 11, 2014 10:51 am

move through lines of two fields

Post by francof » Sat Aug 30, 2014 3:34 pm

Hi all, another strange question.

I've 2 list field filled with data (fldA, fldB)
after clicking on a line of fldA I must move to the previous, next line of it with 2 different buttons (btnDwn, btnUp) and hilite the new line.
the same with fldB.
Hendlers of the buttons should be the same for the 2 fields.

how can I tell to the buttons on which field I've clicked before?
can I store the name of the field selected to use in the buttons hndlers?

ciao
franco

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

Re: move through lines of two fields

Post by jmburnod » Sat Aug 30, 2014 4:02 pm

Hi Franco,
how can I tell to the buttons on which field I've clicked before?
can I store the name of the field selected to use in the buttons hndlers?
You can use a customprop

Code: Select all

set the uMyWorkField of this cd to the short name of the target
or variable

Code: Select all

put the short name of the target into gMyWorkField
And use it to know which field is working
Best regards
Jean-Marc
https://alternatic.ch

francof
Posts: 237
Joined: Fri Apr 11, 2014 10:51 am

Re: move through lines of two fields

Post by francof » Sat Aug 30, 2014 5:36 pm

Hi Jean-Marc,
thanks a lot. just one thing, you wrote to set the custom property of this cd (card), maybe you meant of fld "myfld" ?
so it work

Code: Select all

set the cNomeFld of fld "fldDoc" to the short name of the target
and something like this in the btnDwn script to move down through le lines

Code: Select all

on mouseUp
   put the cNomeFld of fld "fldDoc" into tNomeFld
   
   put the hilitedline of fld tNomeFld into tLineNumber                 ## What line has been clicked:
   add 1 to tLineNumber
  set the hilitedline of fld tNomeFld to tLineNumber
end mouseUp
there is a problem here:
"put the cNomeFld of fld "fldDoc" into tNomeFld" I must declare the name of the object. so, we return to the initial problem, some time the filed will be "fldA" other will be "fldB"

maybe better a global variable like in your second option, to put empty before to use.

ciao
franco

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

Re: move through lines of two fields

Post by jmburnod » Sat Aug 30, 2014 5:57 pm

Hi Franco,
you wrote to set the custom property of this cd (card), maybe you meant of fld "myf
No.That can't work like
then
When a line is cliqued on a fld

Code: Select all

set the cNomeFld of this cd to the short name of the target
and in btn

Code: Select all

on mouseUp
   put the cNomeFld of this cd into tNomeFld
   put the hilitedlines of fld tNomeFld into tLineNumber                 ## What line has been clicked:
   add 1 to tLineNumber
  set the hilitedline of fld tNomeFld to tLineNumber
end mouseUp
Best regards
P.S. You have maybe to decide if you can have two flds with selected lines or not
https://alternatic.ch

francof
Posts: 237
Joined: Fri Apr 11, 2014 10:51 am

Re: move through lines of two fields

Post by francof » Sat Aug 30, 2014 6:37 pm

Jean-Marc,
I'm late.. and yuk :oops:
I was in the shower when, like lightning in my head, I understood your suggestion.
the custom property of the card, is available to set and is unique from any script, it works great.
jmburnod wrote: ...
P.S. You have maybe to decide if you can have two flds with selected lines or not
this was settled yet. in the mouse up of each filed:

Code: Select all

set the hilitedline of fld fldDoc to 0
thanks again, ciao
franco

Post Reply