How to copy nested groups?

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
MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

How to copy nested groups?

Post by MaxV » Wed Jul 31, 2013 1:27 pm

Hi all,
I have a very complex group. This group contains a button that it shows/hide a nested group inside it ("fromDatePicker").
Button code:

Code: Select all

on mouseUp
if the Visible of group "fromDatePicker"  = false then
      set the Visible of group "fromDatePicker"  to true      
   else 
      set the Visible of group "fromDatePicker"  to false
   end if  
end mouseUp
I need to duplicate it many time in the same card, but all the new button show/hide always "fromDatPicker" of the first group.

Is there any syntax like "button Hello of this group"?
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10331
Joined: Wed May 06, 2009 2:28 pm

Re: How to copy nested groups?

Post by dunbarx » Wed Jul 31, 2013 2:26 pm

I am not sure what you need.

Do you want to duplicate the button itself? Why? What would more buttons do for you? Would each new one hide/show a different group? To distinguish one button from another you can change their names, of course, and refer to them in that way.

You can shorten your script:

Code: Select all

on mouseup
set the visible of group "fromDatepicker" to not the visible of group "fromDatePicker"
end mouseup
But that was not your problem. Please write back with more details.

Craig Newman

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

Re: How to copy nested groups?

Post by Mark » Wed Jul 31, 2013 2:27 pm

Hi,

I'd make a template group in a different stack (not protected by a password) and use syntax such as

Code: Select all

copy grp id 1234 of stack "Your Template Stack" to cd 1 of stack "Your Destination Stack"
put it into myGrp
hide grp "FromDatePicker" of myGrp
This syntax assumes that group "FromDatePicker" is part of another group. (I'm not sure if I understand that correctly).

Edit:
Reading Bernd's solution, I think he understands what the problem is and his solution will work.

Kind regards,

Mark
Last edited by Mark on Wed Jul 31, 2013 2:45 pm, edited 1 time in total.
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

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

Re: How to copy nested groups?

Post by bn » Wed Jul 31, 2013 2:40 pm

Hi Max,

if the button is in the same group as the datePicker then

Code: Select all

on mouseup
set the visible of group "fromDatepicker" of the owner of me to not the visible of group "fromDatePicker" of the owner of me
end mouseup
owner of me tells the button to operate on group "fromDatePicker" that belongs to the same group as the button you are clicking.
this is the equivalent of "like "button Hello of this group"?"

Kind regards
Bernd

MaxV
Posts: 1580
Joined: Tue May 28, 2013 2:20 pm
Contact:

Re: How to copy nested groups?

Post by MaxV » Wed Jul 31, 2013 3:09 pm

THANK YOU!
On the owner of me is what I was looking for! :-)
Livecode Wiki: http://livecode.wikia.com
My blog: https://livecode-blogger.blogspot.com
To post code use this: http://tinyurl.com/ogp6d5w

Post Reply