Setting up an Option Menu Button

Terence Heaford t.heaford at btinternet.com
Thu Mar 13 07:40:39 EDT 2014


I have an Option Menu on a card accessed from other cards where I want to select item 1 of the menu whenever you go to the card.

The Card that owns Option Menu Button is also accessed from a Tab Panel.

I have this script that is used to setup the button and sometimes it works and other times it doesn’t.

When I say doesn’t, the ellipsis are not added.

Can someone point me in the right direction please:

--------
This is the Tab Panel Script
--------
on menuPick pItemName
   switch pItemName
      case "General"
         go to cd "ChartGeneral"
         break
      case "Categories"
         go to cd "ChartCategories"
         break
      case "5 Year Categories"
         go to cd "Chart5YearCategories"
         put revDataFromQuery(tab, return, the uDB of stack “MyStack", "select categoryName from 'categoryList' order by categoryName asc") into tCatNames
         set the text of cd btn "CategoryMenu" to tCatNames
         --send "menuPick " & line 1 of tCatNames to cd btn "CategoryMenu"
         dispatch "menuPick" to cd btn "CategoryMenu" of cd "Chart5YearCategories" with line 1 of tCatNames
         set the menuHistory of cd btn "CategoryMenu" to 1
         break
   end switch
end menuPick

--------
This is the Option Menu Script
--------
on menuPick pItemName
   lock screen
   addEllipsis the long name of me,pItemName
   unlock screen
end menuPick

--------
The following method is in the stack script to make it available to other menu’s elsewhere.
--------
on addEllipsis pName,pChoice
   lock screen
   put the width of pName - 15 into tW
   set the label of pName to pChoice
   put the formattedWidth of pName into tSize
   if tSize > tW then
      repeat with x = length(pChoice) down to 1
         set the label of pName to (char 1 to x of pChoice) & "..."
         if the formattedWidth of pName < tW then
            exit repeat
         else
            put x-1 into tMax
            put char 1 to tMax of pChoice & "..." into tLabel
         end if
      end repeat
      set the label of pName to tLabel
   end if
   unlock screen
end addEllipsis


More information about the use-livecode mailing list