Pulldown menus

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
stephenlewis
Posts: 8
Joined: Sun Nov 16, 2014 3:05 am

Pulldown menus

Post by stephenlewis » Thu Nov 20, 2014 1:22 am

Hi Guys

Got myself all turned around again!! On a card I'm trying to create a pull down menu which is populated by the contents of three fields. As the content of the fields change so do the menu items. The user can then choose an item and the relevant field content is displayed. I've created a substack with the three fields on it and linked this to a button on my card. When I click on the button the substack card opens with three fields displayed. However, this isn't what I'm after. Could someone point me in the direction of a script example to get me moving in the right direction? Just how do I get the content of three fields to populate a pull down menu? Thanks
Stephen
www.landscapesofwales.co.uk

[-hh]
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2262
Joined: Thu Feb 28, 2013 11:52 pm

Re: Pulldown menus

Post by [-hh] » Thu Nov 20, 2014 1:44 am

Hi.
You could try this.
Fields are preferably list fields or non-wrapping fields, script of the menu button:
Instead of "fld 1" etc you have to write a closer identifying epression, may be
fld 1 of card 1 of stack "yoursubstack"
or so. Just try.

Code: Select all

local fldLineNums
on menuPick
  put the menuhistory of me into n0
  switch
    case n0 <= item 1 of fldLineNums; select before line n0 of fld 1; break
    case n0 <= item 2 of fldLineNums
      select before line (n0 - item 1 of  fldLineNums) of fld 2; break
    default; select before line (n0-item 2 of fldLineNums) of fld 3; break
   end switch
end menuPick

on mouseDown
   put the num of lines of fld 1 &","& the num of lines of fld 2 into  fldLineNums
   put fld 1 & cr & fld 2 & cr & fld 3 into me
end mouseDown
shiftLock happens

stephenlewis
Posts: 8
Joined: Sun Nov 16, 2014 3:05 am

Re: Pulldown menus

Post by stephenlewis » Thu Nov 20, 2014 2:09 am

Many thanks!! That works fine, although I'll take time out to sort out exactly what's happening! Cheers.
Stephen
www.landscapesofwales.co.uk

Post Reply