Home › Forums › General › Programming › popup menu actions? (how?) › Reply To: popup menu actions? (how?)
September 3, 2017 at 12:18 pm
#72820
EDIT: now this should work
I don’t know how to get a text from a menu item, but maybe this would work:
-- Create a table for menu item names
itemNames =
{
"blablabla",
"blablabla2",
"blablabla3"
}
-- Create a popupMenu
local pMenu = PopupMenu()
-- Create menu items from the "itemNames" -table
for itemIndex=1, #itemNames do
pMenu:addColouredItem(itemIndex, itemNames[itemIndex], Colour(0xff21c630), true, false, Image())
end
-- Show the menu
local ret = pMenu:show(0,0,0,0)
-- Return if nothing is selected
if ret == 0 then
return
end
-- Print the correct name from the "itemNames" -table
-- Here you could send the name to a label
console(itemNames[ret])