Home › Forums › General › Programming › popup menu actions? (how?)
Tagged: Popup Menu
- This topic has 24 replies, 3 voices, and was last updated 6 years, 6 months ago by human fly.
-
AuthorPosts
-
September 4, 2017 at 10:07 am #72841
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
September 4, 2017 at 10:15 am #72842little 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)September 4, 2017 at 1:49 pm #72843CORRECTION 😀
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/3ari4lovw0h1lzp0ynezas9oci5ceyntthis:(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 6 years, 7 months ago by human fly. Reason: add demo file
September 22, 2017 at 1:09 pm #73025little 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…
September 24, 2017 at 8:27 am #73082noticing 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?
-
AuthorPosts
- The forum ‘Programming’ is closed to new topics and replies.