Page 1 of 1

Path from group to card

Posted: Wed Aug 22, 2012 3:33 pm
by david.silmanBUSrUeQ
Ok guys, I'm making my own control, effectively a data tree (yes I know there are ones out there that I could use, but I want to make my own)

the situation is, I want to keep the code as separate from the control as possible, so I'm designing the elements on a stack that will effectively be used as a library (henceforth referred to as the library stack)
The code for the control will sit on the library stack and the actual grouped objects will call the commands and functions that they need, basically trying to make it into a class as much as livecode can do.

The problem is that when I copy the tree to a new card/stack, I need to know the exact number of groups it is embedded in, as it could vary, this mainly affects things like changing images

Code: Select all

set the filename of img "img" of group "...." and so on on card "card ..." on stack "stack ..."
but so far I've found that to do something like that you need to specify each and every group all the way up to the card, such:

Code: Select all

set the filename of img "img" of group "a" of group "b" of group "c" ... of group "n" on card...
is there any simple way of doing this? Or am I going to have to restrict it in some way?

Cheers
David

Re: Path from group to card

Posted: Wed Aug 22, 2012 3:44 pm
by Klaus
Hi David,
david.silmanBUSrUeQ wrote:...but so far I've found that to do something like that you need to specify each and every group all the way up to the card, such:...
I'm afraid that's the way LiveCode works, you need to exactly address objects.

Maybe you could use some "getprop" or "setprop" handlers in the groups so they can reference "me" in the scripts.
But I have no idea of your app design, so I can only guess vaguely 8)


Best

Klaus

Re: Path from group to card

Posted: Wed Aug 22, 2012 4:14 pm
by david.silmanBUSrUeQ
Thanks for the fast reply.

How could I use setProp and getProp to allow the objected to be referred to as "me"?

I'll try and explain it a bit more, sorry if this is more confusing:

I have a stack that I'm effectively using as a library, on this stack I have my objects and code, the code being on the card itself and the object's script calls the commands from the cards script.

The control would then be copied to wherever it's needed. But that could be inside any number of groups.

cheers
David