Getting the "owner" of a control

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
phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Getting the "owner" of a control

Post by phaworth » Thu Aug 06, 2009 7:37 pm

I have a need to to find out whether an object on a card is part of a group or placed directly on the card, and then to get the name of the group or card. If the object is in a group, I would have to allow for the fact that the group may be part of another group.

Is there a way to traverse the hierarchy of objects that an object belongs to?

Thanks,
Pete

Klaus
Posts: 14190
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Thu Aug 06, 2009 7:42 pm

Hi Pete,

you won't believe it, but check "owner" in the docs (Revolution Dictionary) :D


Best

Klaus

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Post by phaworth » Thu Aug 06, 2009 7:47 pm

Thanks Klaus!!! I guess RTFM should be my mantra!

I guess I may be missing this but is there a place in any of the documentation where you can list all the properties and messages related to a particular type of object? In other words, I search,eg, for "Field" and get a list of all the messages/properties associated with any field object.

Thanks,

Pete

Klaus
Posts: 14190
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Thu Aug 06, 2009 8:26 pm

Hi Pete,

well, on the left side of the "Rev Dictionary" there is a "tree" list field which lists all Rev objects (and more) and when clicked will show all the props for this kind of object.

I think this is since version 3 (?).


Best

Klaus

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Post by phaworth » Fri Aug 14, 2009 9:55 pm

OK, so now I'm looking for the reverse of the above. For example, given a group name/id, how do I get a list of all the objects that are in that group? Right now, I'm going through every object on the card and checking its owner, but hoping there's a more efficient way to do it.
Thanks,
Pete

Klaus
Posts: 14190
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Post by Klaus » Sat Aug 15, 2009 11:02 am

Hi Pete,

in that case it is even easier:
...
put the num of controls of grp "Your geoup here" into xyz
...
put the num of buttons of grp ...
...
put the num of fields of grp ...
...
etc.

No need to check the owner if you knwo the name/number/ID of the group!


Best

Klaus

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Sat Aug 15, 2009 2:36 pm

Dear Pete,

You might want to check the two handlers available at http://runrev.info/Objects%20list.htm . These two getProp handlers return a list of controls of any group, card or stack. Just use the syntax

Code: Select all

put the objects of group 1 into myObjects1
put the objects of this stack into myObjects2
Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

phaworth
Posts: 592
Joined: Thu Jun 11, 2009 9:51 pm

Post by phaworth » Sat Aug 15, 2009 5:03 pm

Thanks Mark, Looks like that will do the job.
Pete

Post Reply