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: 665
Joined: Tue Jul 29, 2014 12:52 am

Setting a property of one group member inside another group

Post by simon.schvartzman » Tue Jan 24, 2017 6:01 pm

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 209 times
Simon
________________________________________
To ";" or not to ";" that is the question

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

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

Post by bn » Tue Jan 24, 2017 6:17 pm

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: 10354
Joined: Wed May 06, 2009 2:28 pm

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

Post by dunbarx » Tue Jan 24, 2017 6:27 pm

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: 665
Joined: Tue Jul 29, 2014 12:52 am

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

Post by simon.schvartzman » Tue Jan 24, 2017 6:49 pm

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 ";" or not to ";" that is the question

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4174
Joined: Sun Jan 07, 2007 9:12 pm

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

Post by bn » Tue Jan 24, 2017 7:03 pm

Simon

try this stack. It works for me.

Kind regards
Bernd
Attachments
groupInGroup.livecode.zip
(1.31 KiB) Downloaded 234 times

simon.schvartzman
Posts: 665
Joined: Tue Jul 29, 2014 12:52 am

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

Post by simon.schvartzman » Tue Jan 24, 2017 7:24 pm

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

Post Reply