Popup menu selection

Richard Gaskin ambassador at fourthworld.com
Thu Feb 18 10:33:14 EST 2010


Jeffrey Massung wrote:

 > I have a couple pop-up button menus that I create on-the-fly
 > (in mouseDown) based on what's going on. They also act as combo
 > box selections, where one of the items is "current," with "!r"
 > in front of it.
 >
 > Is it possible for me to somehow tell the popup to auto-magically
 > scroll down to the current selection instead of always reopening
 > the menu at the top?

To set the current selection of an option control you set its 
menuHistory property.  But note that setting that property also 
trigger's the button's menuPick handler, which can be problematic in 
some circumstances.

To counter this, Ken Ray and I have adopted a habit of using a handler 
like this one to set an option control's current choice:

on SetOption pBtnName, pNum
    lock messages
    set the menuHistory of btn pBtnName to pNum
    unlock messages
end SetOption

It would be ideal if the language provided a native command for this, 
but tucking this into your standard library at least gets the job down 
for now.

--
  Richard Gaskin
  Fourth World
  Rev training and consulting: http://www.fourthworld.com
  Webzine for Rev developers: http://www.revjournal.com
  revJournal blog: http://revjournal.com/blog.irv



More information about the use-livecode mailing list