Stack as Menu example? [SOLVED]

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
Garrett
Posts: 386
Joined: Sat Apr 08, 2006 8:15 am
Contact:

Stack as Menu example? [SOLVED]

Post by Garrett » Sat Aug 09, 2014 5:12 pm

Was looking around for an example of using a stack as a menu but couldn't find anything. Tried winging it and made my own.. but yeah, it don't work as it should. By chance does anyone have an example of using a stack as a menu?

Thanks,
~Garrett
Last edited by Garrett on Sun Aug 10, 2014 6:23 pm, edited 1 time in total.
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)

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

Re: Stack as Menu example?

Post by dunbarx » Sat Aug 09, 2014 5:54 pm

Hi.

When you say "use stack as a menu" are you trying to create a custom "ask" or "answer" dialog?

Craig Newman

Garrett
Posts: 386
Joined: Sat Apr 08, 2006 8:15 am
Contact:

Re: Stack as Menu example?

Post by Garrett » Sat Aug 09, 2014 6:10 pm

No, as a pulldown menu
Displays a pulldown menu whose whose menu items are buttons in a stack.

Code: Select all

on mouseDown
  pulldown stack "Lookup Options"
end mouseDown
I can get the stack with my testing menu on it of a couple buttons to show up as a menu under the button I use the pulldown command, but I can't figure out how to get the buttons on the menu stack to actually act/react like a menu.
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Stack as Menu example?

Post by jmburnod » Sat Aug 09, 2014 7:02 pm

Hi Garrett,

It works for me.
I think you have to use the path of the stack instead the short name

Code: Select all

on mouseDown
   answer file "open"
   if it = empty then exit mousedown
    pulldown stack it
end mouseDown
Jean-Marc
https://alternatic.ch

Garrett
Posts: 386
Joined: Sat Apr 08, 2006 8:15 am
Contact:

Re: Stack as Menu example?

Post by Garrett » Sat Aug 09, 2014 9:56 pm

The stack itself is not the problem, when I click the button assigned to pulldown the stack as a menu, that works. What I don't know how to do is setup the stack itself with the buttons to work like a menu.

Thanks,
~Garrett
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)

Da_Elf
Posts: 311
Joined: Sun Apr 27, 2014 2:45 am

Re: Stack as Menu example?

Post by Da_Elf » Sat Aug 09, 2014 9:59 pm

why a stack? put some buttons over a rectangle into a group and show or hide them on click/rollover or rollout and it keeps it all on 1 card

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Stack as Menu example?

Post by jmburnod » Sun Aug 10, 2014 10:56 am

Hi Garrett,
For menus I always use groups as said Da_Elf.
how to do is setup the stack itself with the buttons to work like a menu.
If you have good reasons to use stack like menu and if it use handlers of the main stack, I think you have to use "start using stack" .
Something like that:

Code: Select all

on mousedown
   put the short name of this stack into tStartStack
   pulldown stack the uMyStackMenu of this stack -- uMyStackMenu contains the path of menustack
   if tStartStack is not among the lines of the stacksInUse then start using stack tStartStack
end mousedown
Best regards
Jean-Marc
https://alternatic.ch

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10045
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Stack as Menu example?

Post by FourthWorld » Sun Aug 10, 2014 5:16 pm

Garrett wrote:The stack itself is not the problem, when I click the button assigned to pulldown the stack as a menu, that works. What I don't know how to do is setup the stack itself with the buttons to work like a menu.
Just put the buttons on with their autoArm and armFill properties set and and it works.

You don't even need to use the pulldown command, instead just set the main menu's menuName property to the short name of the stack you want it to display.

There's a bug in the current stable version of LC (6.6.2) which prevents the main menu button from getting the menuPick message, but apparently this has been fixed for v6.7 dp 8 and 7.0 dp 9.

Note that using stacks as pulldown menus only works on Windows and Linux, and not on Mac. To accommodate the Mac's global menu bar, LiveCode's ordinary handling of menus is translated to Mac APIs, which aren't compatible with LC stacks.

Even on Windows and Linux, the behavior is a bit funky at times. In the olden days (early '90s), the original engine was released for Unix only, and all menus were implemented as stacks. With the Windows port in '96/'97, the menus were revamped to use a list of strings instead, and for normal-looking menus it's really much easier to just use the modern string method.

One thing stack menus can be good for is galleries or other unusual menus, but given that they can't be used on Mac as pulldowns from the global menu bar I tend to use an icon within the window for those.

Also, keep in mind that the behavior of stack menus is very limited, only supporting the same interaction as a normal menu: items hilite as the mouse is moved over them, and once anything in the stack is clicked the menu stack is dismissed. So if you need any other type of interation (controls requiring multiple clicks, sliders, etc.) better to consider a panel-like view using a borderless palette instead.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7390
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Stack as Menu example?

Post by jacque » Sun Aug 10, 2014 6:12 pm

I'm not sure if the stack menu is for the main system menu or for a popup button. If used with a button it will work on Mac. In that case, each stack button must have its own mouseUp handler that calls a command on the current card or executes its own handler.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Garrett
Posts: 386
Joined: Sat Apr 08, 2006 8:15 am
Contact:

Re: Stack as Menu example? [SOLVED]

Post by Garrett » Sun Aug 10, 2014 6:22 pm

Thank you Richard, that's what I needed :-)

It's a Linux only program. I just wanted to replicate the menus being used on the distribution I use. The popup menu did not quite allow for me to change it's properties enough to replicate the menus the desktop is using, mainly removing threeD, setting borderwidth to 1, width of the menu itself, margins of each entry.

~Garrett
'What you do not want done to yourself, do not do to others.' - Confucius (550 b.c. to 479 b.c.)

Post Reply