Cascading Menu Trouble

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
peter.s
Posts: 99
Joined: Thu Jul 10, 2008 11:47 am

Cascading Menu Trouble

Post by peter.s » Wed Apr 30, 2014 5:35 pm

Hi there,

I can't figure out how to select items in a cascading menu button. I can get a simple menu button working just fine, and I can build a cascading menu - but writing the code for the extra submenu layer has thrown me.

This is a standard menu button from the dictionary

Code: Select all

on menuPick theMenuItem 
switch theMenuItem
case "Name of First Item" 
-- do stuff here for first item
break 
case "Name of Second Item"
-- do stuff here for second item 
break
case "Name of Third Item" 
-- do stuff here for third item
break 
end switch 
end menuPick
Can someone show me how to incorporate a submenu - lets say "Name of First Item", with "Submenu Item One", and "Submenu Item Two" ?

Cheers

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

Re: Cascading Menu Trouble

Post by Klaus » Wed Apr 30, 2014 6:02 pm

Hi Peter,

the "(sub)menuitems" are returned in this format for "cascading" menus, separated with a pipe |:
Name of First Item|Submenu Item One
Name of First Item|Submenu Item Two|Submenu item Three|etc...

So you could check the number of items and do something like this:
...
set itemdel to "|"
## Answer first submenu e.g. -> Submenu Item One
answer item 2 of theMenuItem
...

Best

Klaus

peter.s
Posts: 99
Joined: Thu Jul 10, 2008 11:47 am

Re: Cascading Menu Trouble

Post by peter.s » Sun May 04, 2014 1:06 pm

Thanks for responding Klaus.

I've been trying a few things but I'm still not getting it... and I realised that perhaps I wasn't very clear in my original post.

I'm having trouble with the MenuPick message. The user guide I have is not very clear about this. My reckoning is that it should look something like this:

Code: Select all

on menuPick theMenuItem
   switch theMenuItem
      case menuitem "First Item|Subitem One" of me
         --do stuff
         break
       case menuitem "First Item|Subitem Two" of me
         --do stuff
         break
But I'm obviously doing something wrong as it isn't working :-) Any advice?

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

Re: Cascading Menu Trouble

Post by Klaus » Sun May 04, 2014 1:41 pm

Hi Peter,

do this:

Code: Select all

on menuPick theMenuItem
   switch theMenuItem
      case "First Item|Subitem One"
         --do stuff
         break
       case "First Item|Subitem Two"
         --do stuff
         break
...
Best

Klaus

peter.s
Posts: 99
Joined: Thu Jul 10, 2008 11:47 am

Re: Cascading Menu Trouble

Post by peter.s » Sun May 04, 2014 8:15 pm

Thanks Klaus - that works!

Post Reply