Data-Grid usage

J. Landman Gay jacque at hyperactivesw.com
Sat Aug 3 11:15:36 EDT 2013


On 8/2/13 1:26 PM, Vaughn Clement wrote:
> Hi
>
> (New to LiveCode)
>
> I would like to have a stack index or contents for each card where I
> determine the fields in the data-grid. I would also like to have a control
> in the row that would go to the card for the data in the row.

I agree with Craig that researching and following hints is a great way 
to learn, but when you're really, really new, sometimes you need a 
little more than that to get started without being too frustrated.

I would not use a datagrid for what you want, it's way overkill. All you 
need is a simple list field. What you want to do is pretty common, 
here's how I do it:

Name each card descriptively and uniquely. That is, name it with the 
same string that should appear in the list.

On the index card that has the list field, you can populate the list in 
one line of code:

    put the cardnames of this stack into field "listField" -- put the 
actual name of the field in the quotes

Now you have automatic linkages, and all you need to do is script the 
field to respond to a click:

on mouseUp
  put the clicktext into tCardName
  go card tCardName
end mouseUp

This can be further reduced to a single line:

   go card (the clicktext)

Normally the clicktext returns only the word under the mouse, but in a 
list field it returns the entire line. That's why this works.

If your stack is static and no cards are ever removed or added, you can 
put the cardnames into the list field once from the message box during 
development and forget about it. If the cards will change, then you'd 
want to execute that statement in a preOpenCard handler in the card 
script so that it will update every time the card opens.

I now return you to generic hint mode. :)

-- 
Jacqueline Landman Gay         |     jacque at hyperactivesw.com
HyperActive Software           |     http://www.hyperactivesw.com




More information about the use-livecode mailing list