Reply To: popup menu actions? (how?)

Home Forums General Programming popup menu actions? (how?) Reply To: popup menu actions? (how?)

#72820
spk77
Participant
    • Topics: 0
    • Replies: 11
    • Total: 11

    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])
    • This reply was modified 6 years, 7 months ago by spk77.
    • This reply was modified 6 years, 7 months ago by spk77.
    • This reply was modified 6 years, 7 months ago by spk77.
    • This reply was modified 6 years, 7 months ago by spk77.
    Ctrlr