Setting a property of one group member inside another group

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
simon.schvartzman
Posts: 672
Joined: Tue Jul 29, 2014 12:52 am

Setting a property of one group member inside another group

Post by simon.schvartzman »

I have a card with one "big" group named BigGroup that consists of 5 small groups called SmallGroup including one graphic (Rounded Rectangle) and one label each (Label).

Who can show me the best way to write the script that will let me set the linesize property of the Rounded Rectangle over which the user has clicked (or tapped).

As always, many thanks in advance
Big&SmallGroups.livecode.zip
(1.13 KiB) Downloaded 258 times
Simon
________________________________________
To "AI", or not to "AI", that is the question
bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4219
Joined: Sun Jan 07, 2007 9:12 pm

Re: Setting a property of one group member inside another gr

Post by bn »

Hi Simon,

try this as script of the BigGroup

Code: Select all

on mouseUp
   put the target into tTarget
   put the long id of the owner of the target into tOwner
   if the owner of tOwner is me then
      lock screen
      repeat with i = 1 to the number of groups of me
         set the lineSize of grc 1 of group i of me to 1
      end repeat
      set the lineSize of grc 1 of tOwner to 4
      unlock screen
   end if
end mouseUp
This works as long as there is only one graphic in the smallGroups.

Kind regards
Bernd
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10501
Joined: Wed May 06, 2009 2:28 pm

Re: Setting a property of one group member inside another gr

Post by dunbarx »

Perhaps I am misunderstanding.

What is wrong with:

Code: Select all

on mouseUp
   ask "Enter lineSize"
   set the lineSize of the target to it
end mouseUp
Now you could always first check the target to make sure it is a graphic, or even a particular graphic. Grouping, however nested, is transparent to "the target".

Craig Newman
simon.schvartzman
Posts: 672
Joined: Tue Jul 29, 2014 12:52 am

Re: Setting a property of one group member inside another gr

Post by simon.schvartzman »

Craig and Bernd, many thanks to both of you for your answers.

Bernd, the script never gets into the repeat loop because it seems "the owner of tOwner" is never equal to "me".
Simon
________________________________________
To "AI", or not to "AI", that is the question
bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4219
Joined: Sun Jan 07, 2007 9:12 pm

Re: Setting a property of one group member inside another gr

Post by bn »

Simon

try this stack. It works for me.

Kind regards
Bernd
Attachments
groupInGroup.livecode.zip
(1.31 KiB) Downloaded 292 times
simon.schvartzman
Posts: 672
Joined: Tue Jul 29, 2014 12:52 am

Re: Setting a property of one group member inside another gr

Post by simon.schvartzman »

Dear Bernd, works like a charm, many thanks!
Simon
________________________________________
To "AI", or not to "AI", that is the question
Post Reply