Getting Menus on Another Stack

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm

Getting Menus on Another Stack

Post by lohill » Sat Mar 06, 2010 6:53 pm

What is the best way to get a menubar group from one stack onto another stack without having to reconstruct it from the MenuBuilder?
I can't seem to copy and paste and when I try to do it programatically I get an error message. Here is the script for a button that I think should do it:

Code: Select all

on mouseUp
   if there is not a group "Menubar 1" on card 1 of stack "PM Contents" then
      place group "Menubar 1" of  card 1 of stack "Portfolio Manager" onto card 1 of stack "PM Contents"
   end if
end mouseUp
I get this error message:
button "Button": execution error at line 3 (place: group is not in this stack or is already on this card), char 1
In the Application Browser, I can clearly see MenuBar 1 in the single card of the stack Portfolio Manager. In the stack PM Contents I do NOT see the group. Also in the 'run' mode I see two completely different menus for those stacks.

The following two scripts which check for the presence of those menus both answer with "Yes". Any ideas?

Code: Select all

on mouseUp
   if there is not a group "Menubar 1" on card 1 of stack "PM Contents" then
      answer "Yes"
   end if
end mouseUp

Code: Select all

on mouseUp
   if there is a group "Menubar 1" on card 1 of stack "Portfolio Manager" then
      answer "Yes"
   end if
end mouseUp
Any suggestions would be appreciated.

Larry

alemrantareq
Posts: 203
Joined: Wed Jul 23, 2008 8:46 am

Re: Getting Menus on Another Stack

Post by alemrantareq » Sun Mar 07, 2010 7:58 am

lohill,

try this -

Code: Select all

on mouseUp
   if there is not a grp "Menubar 1" on card 1 of stack "PM Contents" then
      copy grp "Menubar 1" of  card 1 of stack "Portfolio Manager" to card 1 of stack "PM Contents"
   end if
end mouseUp
Hope it'd solve your problem.

lohill
Posts: 770
Joined: Tue Dec 08, 2009 6:37 pm

Re: Getting Menus on Another Stack

Post by lohill » Sun Mar 07, 2010 4:37 pm

Thanks alemrantareq,

That worked like a charm. Is it safe to say that 'copy - to' is always a better choice than 'place - onto' for situations like this? Are there situations where 'place - onto' is required?

Regards,
Larry

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

Re: Getting Menus on Another Stack

Post by Klaus » Sun Mar 07, 2010 5:04 pm

Hi Larry,

you can only "place" backgrounds "onto" cards in the same stack, not across stacks!
That's why you need to copy here :)


Best

Klaus

Post Reply