Cascading menu question

Klaus Major k_major at
Sat Dec 14 07:31:01 EST 2002

Hi Mark,

> I have a menu which is called Appearance... one of the menuitems is 
> "Set
> background image to..." and I would like to have a cascading menu 
> coming off
> this which will display the contents of an image folder.  Choosing one 
> of
> these image files will then set the image of a graphic to that 
> particular
> file.
> Can anyone explain to me how to accomplish this?
> Thanks,
> Mark

try this:

This example presumes that your images are in the active directory.
Please drop a line, if they are in another folder. That will require
a little bit more scripting.

on opencard
## or whenever you want to prepare that button...
    get the files  ##!!!
    repeat for each line xxx in it
       put TAB & xxx & CR after my_images
    end repeat
   ## "repeat for each" is insanely fast ;-)
   ## but read-only. So we just fill another variable
  ## with the stuff that we need...
  ##Imn this case a TAB for each level of submenus
   delete char -1 of my_images
   get btn "Your button name here!"
   put CR & my_images after line \
            lineoffset("Set background image to...", it) of btn "Your 
button name here!"
end opencard

Now your button has the correct submenus.

Now you will have to script this in that button:

on menupick which
   set the itemdel to "|“
  ## This is the itemdel for submenus
  ## Submenus are seen by the engine as "menuitem1|submenu1!
   switch item 1 of which
      case "Set background image to..."
        set the filename of img "Your image here!"  to item 2 of which
   end switch
end menupick

Hope this helps.

Have a nice weekend.


Klaus Major
k_major at

More information about the Use-livecode mailing list