popup menu actions? (how?)

Home Forums General Programming popup menu actions? (how?)

Tagged: 

Viewing 5 posts - 21 through 25 (of 25 total)
  • Author
    Posts
  • #72841
    human fly
    Participant
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    hi – ok, i’ve reproduced your code, and i’m getting this error
    (what do we call this type of error? syntax?)

    At line [-1]: [C]
    What: C
    Namewhat: method
    Name: addColouredItem
    Error message: No matching overload found, candidates:
    void addColouredItem(PopupMenu&,int,String const&,Colour,bool,bool,Image const&)
    void addColouredItem(PopupMenu&,int,String const&,Colour,bool,bool,Drawable*)

    am i correct in thinking it is failing at ‘image()’?
    here is what my copy of your code looks like:

    function colourPop2()
    
    	--This stops issues during panel bootup--else popup will hang startup!
    	if panel:getRestoreState() == true or panel:getProgramState() == true 
    	then return end
    
    -- Create a table for menu item names
    	itemNames = 
    	{
    	"toneName1","toneName2","toneName3","toneName4","toneName5","toneName6","toneName7","toneName8",
    	"toneName9","toneName10",
    	}
    --
    	local pMenu	= PopupMenu()
    
    -- Create menu items from the "itemNames" table
    	for i=1, #itemNames do
    	pMenu:addColouredItem(i, itemNames, Colour(0xff21c630), true, false, Image())
    	end
    --
    	local ret = pMenu:show(0,0,0,0)
    
    --////////////////////////////////////// MENU ACTIONS /////////////////////////////
    -- 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])
    end
    #72842
    human fly
    Participant
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    little side question: this:
    for i=1, #itemNames do ...

    so am i correct in reading this as ‘ for ‘i’ items starting at 1,
    go through consecutively all items in table ‘itemNames’ ‘ ?

    (kinda inverse way of learning about this 🙂 but whatever it takes..
    i keep meaning to get back to these basics)

    #72843
    human fly
    Participant
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    CORRECTION 😀
    it DOES work ! i had it completely wrong, for some reason,
    i see what you mean about the square brackets now. i must’ve
    copied it wrong.

    demo panel here:(popupwerk_v03.panel)
    https://app.box.com/s/3ari4lovw0h1lzp0ynezas9oci5ceynt

    this:(exactly as you showed in your post)

    -- Create menu items from the "itemNames" table
    	for itemIndex=1, #itemNames do
    	pMenu:addColouredItem(itemIndex, itemNames[itemIndex], Colour(0xff21c630), true, false, Image())
    	end

    then this:

    
    panel:getComponent("label_ToneNameDest"):setPropertyString("uiLabelText"," " .. (itemNames[ret]))

    it is a nice way to do a simple popup menu, as well – although
    i don’t know how one might do headers and submenus.

    now we just have to find out how to do all those other natty tricks
    with background colour/trnasparency etc. – i wonder if there are
    ways to adapt your code to work it in the ‘standard’ way of
    creating popups.

    • This reply was modified 4 years, 9 months ago by human fly. Reason: add demo file
    #73025
    human fly
    Participant
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    little question on popups again:
    how do you define how many rows/columns?
    or more precisely, if i want my items in ‘stacks’ of, say, 8,
    how is that achieved?

    what do these entries represent? i know the last one it item height:
    ret = m:show(0,0,0,25)

    ccheeerzzz…

    edit: ah: answer to that here:

    https://www.juce.com/doc/classPopupMenu#acd7bdfe5db59180d929a5dac90bcacce

    but this doesn’t seem to allow me to organise columns/rows…

    #73082
    human fly
    Participant
    • Topics: 124
    • Replies: 1070
    • Total: 1194
    • ★★★★

    noticing anothing thing about this:
    say you have:

    m 	= PopupMenu()
    m:addItem(1, "A-11", true, false, Image())
    etc?

    ‘ Image()’ is a function. so presumably you could replace
    that with a different function?

    not sure what, at the moment. any thoughts?

Viewing 5 posts - 21 through 25 (of 25 total)
  • The forum ‘Programming’ is closed to new topics and replies.
There is currently 0 users and 53 guests online
No users are currently active
Forum Statistics
Threads: 2,495, Posts: 17,374, Members: 77,605
Most users ever online was 12 on January 22, 2019 3:47 pm
Ctrlr