Images in Menus?
    Martin Blackman 
    martinblackman at gmail.com
       
    Tue Jul 18 10:49:17 EDT 2006
    
    
  
Here is a leaner (read less sophisticated) approach than the example
above for a pulldown menu with images at the right hand end of each
line. I have a substack (with decorations set to empty) with menu
items in a list field with scrollbar. The list field has these 3
scripts -
on mousemove
--change hilited line unless using scrollbar:
  if the mouseH < the right of me - 16 then set the hilitedline of me
to word 2 of the mouseline
end mousemove
on focusout
  close stack "SpecPD"
end focusout
on mouseup
put line (the hilitedline of me) of me into tspec
delete char -2 to -1 of tspec --last 2 chars display a space then an image
put tspec into fld "specPulldown" of stack "Topstack"
-- + other script as required
end mouseup
I have a button & field 'specPulldown' on the main stack setup to look
like a pulldown menu. The button has script something like this,
adding a tick to every menu item that corresponds to a cardname :
on mousedown
  lock cursor  --otherwise hourglass shows (why ?)
  set the right of stack "SpecPD" to the right of me + the left of
stack "Topstack"
  set the top of stack "SpecPD" to the bottom of me + the top of stack
"Topstack" +2
  put the cardnames of stack "Topstack" into tcards
  set the wholematches to true
  put 0 into x
put the cSpeclist of stack "Topstack" into fld "SpecList" of stack "SpecPD"
  repeat for each line tline in the cSpeclist of stack "Topstack" --a
precompiled list
    add 1 to x
    put "  " after line x of fld "SpecList" of stack "SpecPD"
    if lineoffset (tline,tcards) <> 0 then \
        set the imagesource of char -1 of line x of fld "SpecList" of
stack "SpecPD" to 31417  --a user defined image ID
  end repeat
  toplevel stack "SpecPD"
end mousedown
regds
Martin
    
    
More information about the use-livecode
mailing list