Setting up an Option Menu Button

Terence Heaford t.heaford at btinternet.com
Thu Mar 13 12:35:11 EDT 2014


Hi Pete,

Simplified by putting addEllipsis into the menu script.

put the script below into OpenCard handler

on openCard
   put revDataFromQuery(tab, return, the uDB of stack "THFinancials", "select categoryName from 'categoryList' order by categoryName asc") into tCatNames
   set the text of cd btn "CategoryMenu" to tCatNames
   set the menuHistory of cd btn "CategoryMenu" to 2
   put the menuHistory of cd btn "CategoryMenu" into tA
   set the menuHistory of cd btn "CategoryMenu" to 1
   put the menuHistory of cd btn "CategoryMenu" into tB
   put tA & "," & tB
end openCard

put the other methods into the button script

on menuPick pItemName
   lock screen
   addEllipsis pItemName
   unlock screen
end menuPick

on addEllipsis @pItemName
   put the width of me - 15 into tW
   set the label of me to pItemName
   put the formattedWidth of me into tSize
   if tSize > tW then
      repeat with x = length(pItemName) down to 1
         set the label of me to (char 1 to x of pItemName) & "..."
         if the formattedWidth of me < tW then
            exit repeat
         else
            put x-1 into tMax
            put char 1 to tMax of pItemName & "..." into tLabel
         end if
      end repeat
      set the label of me to tLabel
   end if
end addEllipsis


Changed menuHistory to 0 first and then to 1.

Have noted if you use 0 in MenuHistory then it uses 1.

If I use 2 first then it changes to 2 then to 1 but menuPick does not get called.

MenuPick is getting called on openCard but the label with the ellipses is not sticking, it reverts back to pItemName.

If I call menuPick via dropping the menu down it works correctly.


All the best

Terry




On 13 Mar 2014, at 15:34, Peter Haworth <pete at lcsql.com> wrote:

> If the menu history of the button is already 1, no menuPick will be
> generated. Try setting the menu History to zero then 1.
> 




More information about the use-livecode mailing list