Home › Forums › General › Programming › popup menu actions? (how?)
Tagged: Popup Menu
- This topic has 24 replies, 3 voices, and was last updated 6 years, 7 months ago by human fly.
-
AuthorPosts
-
July 31, 2017 at 6:08 pm #72567
Hi again…
just for the hell of it:
i made a little popup menu of all my parameters with
their sysex address, as a quick reference thing.so then i come to the bit that says:
--////////////////////////////////////// MENU ACTIONS ///////////////////////////// if ret ~= nil then
and instead of:
--utils.infoWindow("Menu", "Selected item: "..ret)
i thought i’d try something like:
panel:getModulatorByName("init_result"):getComponent():setProperty("uiLabelText",(ret), false) end
And this doesn’t crash: it just doesn’t do anything. so i figure my code
is wrong. i’m just guessing, actually: ‘ret’ is what the popup selection
*returns*, yeah? – so how do i ‘put’ that in my uiLabelText property?
i tried a few things, then ran out of ideas. it was a while ago. maybe
i should put it back the way it was originally, and see it that does
anything. i just don’t want the dialog, i just want the text to appear
in the destination text object (‘label modulator’).September 2, 2017 at 11:43 am #72808hi again,
getting back to this: returning something from a popup menu selection.i figured out how to get back the item number, and send it to a label,
but don’t know how to get the text entry for that item number – or any
other data associated with it. at present, i’m doing this:my item entries are defined ie:
Tone_params:addItem(1, "toneName1 00 00/VSTindex1", true, false, Image())
and the menu action is:local ret = Tone_params:show(15) if ret ~= nil then panel:getComponent("labelDisplay"):setPropertyString("uiLabelText",""..(ret)) end
all you get for (ret) is the item number. how do you get the text part before
the booleans? -this is just a little thing i am using to have my parameter
names, address hex, and VST index available to look at. won’t be in the final
panel. i’m curious as to how you fetch text that appears in the popup.September 3, 2017 at 6:48 am #72811There’s a pop up menu example in one of Atom’s demo panel’s I think.
The Puppeteer
http://godlike.com.auSeptember 3, 2017 at 8:39 am #72812ok, yes, no doubt i should check again. i have probably
not completed my ‘study’ of popups 🙂
i think i just don’t knw how to refer to the text part of
the item entry. (as i’ve only got as far as creating ‘ret’
here, and getting that to display > i’m currently sending
it to a uiLabel for visual confirmation/feedback)do we have a way of defining popup menu colours?
background and text?*edit* – right, well it works just the same without brackets
around ‘ret’, but still no return of the text associated with
the item number. still only getting item number (that’s the
‘popup menu’ demo. it produces a utils window, which isn’t
what i’m after)September 3, 2017 at 9:53 am #72813possibly…>>
originally, it goes:
ret = Tone_params:show(0,0,0,0)
i changed this, in order to make the rows narrower, to:
ret = Tone_params:show(15)
i really don’t know what the 0,0,0,0 refer to 🙂
it just changed the rows when i varied the first entry, trial
and error/hit’n’miss technique.if a popup menu item entry is defined as:
common_params:addItem(2, "blablabla", true, false, Image())
that’s 5 parameters, including the image – or is it? – so i’m
thinking 0,0,0,0 does not refer to those.
ie: i just want to get “blablabla” onto my labeltext. not ‘2’.
which is what i’m getting at the moment.
have to check-see what happens if i try to define more than
the (15) row height i’m using instead.(hope that’s not too
woolly as an explanation!) – this could be something quite
simple, i’m just not getting the inspiration this morning.anyway, yeah: what i’m suspecting is that the problem is
how i am defining ‘ret’ – of course – isn’t it? 🙂
i’ll have another try.- This reply was modified 6 years, 7 months ago by human fly.
September 3, 2017 at 11:23 am #72816This seem to work for menu item text color:
Tone_params:addColouredItem(1, "toneName1 00 00/VSTindex1", Colour(0xff21c630), true, false, Image())
September 3, 2017 at 11:57 am #72817oh great, thanks ! one more thing resolved 🙂
will try that.
‘addColouredItem’ – for each entry? – where did you find that?
any indication that the popup background might be able to be
coloured? or (…) current selected item ? ;-Di’ve used ‘image()’ for some frames i would otherwise have in
an image strip, that works – can’t remember if i’ve tried to
have coloured ones, these are monochrome atm.edit: hehe !!! yeah GREAT! the popup menu can have that, mixed
with the original basic ‘additem’ entries. that’s cool.now, i wonder how to get at these definitions, so that i can
do the thing of sending the text from the entry to the
labeltext output i’m using..September 3, 2017 at 12:08 pm #72818oh great, thanks ! one more thing resolved
will try that.
‘addColouredItem’ – for each entry? – where did you find that?
any indication that the popup background might be able to be
coloured? or (…) current selected item ? ;-Di’ve used ‘image()’ for some frames i would otherwise have in
an image strip, that works – can’t remember if i’ve tried to
have coloured ones, these are monochrome atm.I found it here
https://www.juce.com/doc/classPopupMenu#abca9890f63f22575c190c0115a1f3acfand here:
https://github.com/RomanKubiak/ctrlr/blob/master/Source/UIComponents/CtrlrMIDI/CtrlrMIDIMon.cpp#L108
I don’t know if it’s possible to change the bg-color…
September 3, 2017 at 12:11 pm #72819Maybe it is possible, but I don’t know how to use this info :)…
https://www.juce.com/doc/classPopupMenu#a0888091ddab0f599bb9d2fab28153f6bPublic Types
enum ColourIds {
backgroundColourId = 0x1000700, textColourId = 0x1000600, headerTextColourId = 0x1000601, highlightedBackgroundColourId = 0x1000900,
highlightedTextColourId = 0x1000800
}
A set of colour IDs to use to change the colour of various aspects of the menu. More…September 3, 2017 at 12:18 pm #72820EDIT: 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])
September 3, 2017 at 12:21 pm #72821looking good, that info. i’m useless at searching the JUCE pages.
i’m seeing: ‘itemText’ and ‘itemResultID'(which must be item number?)
and it all seems to be there on that other JUCE link:
‘backgroundColourId’ah you’ve posted again already 🙂
September 3, 2017 at 12:25 pm #72822Here’s a gif:
Attachments:
You must be logged in to view attached files.September 3, 2017 at 12:31 pm #72824that was quick – is that your popup with green text and black bg?
i tried ‘itemText’ but it didn’t know what it was, returned nil.
maybe my syntax is wrong, and it needs to be inside ” “? try again..woops no that just returns ‘itemText’, of course.
i see you appear to have resolved it. i’ll try that out, thanks.September 3, 2017 at 12:40 pm #72827For some reason, I can’t paste the correct code inside the “code tags”…
This line:
pMenu:addColouredItem(i, itemNames, Colour(0xff21c630), true, false, Image())
should be:
pMenu:addColouredItem(i, itemNames[ i ], Colour(0xff21c630), true, false, Image())edit: square brackets and letter “i” don’t work in this forum…
September 3, 2017 at 12:52 pm #72832i seem to be able to see them here.
i’ll have to try to build this with care separately; i’m having
trouble trying to do it within my current method, as it has
xxx menu entries at the moment. there is stuff there that is new
to me, takes a little while to process 😉 – but i get the gist of it.so i would need, somehow to make my popup refer to the same table
that is used for fetching the itemNames, rather than having it all
doubled up. you’re quick, man 😀am i seeing that you did change that background colour, from your gif?
September 3, 2017 at 12:52 pm #72833Now the code should work…(this forum doesn’t work correctly if there is a letter “i” inside square brackets.)
that was quick – is that your popup with green text and black bg?
That’s just a text label.
September 3, 2017 at 12:55 pm #72834ok, labeltext, got that. i shall try this in a bit and get back.
need food !
thanks for your help!September 3, 2017 at 1:07 pm #72835i seem to be able to see them here.
i’ll have to try to build this with care separately; i’m having
trouble trying to do it within my current method, as it has
xxx menu entries at the moment. there is stuff there that is new
to me, takes a little while to process – but i get the gist of it.so i would need, somehow to make my popup refer to the same table
that is used for fetching the itemNames, rather than having it all
doubled up. you’re quick, manam i seeing that you did change that background colour, from your gif?
I hope there’s a way to get the menu item names – that would be easier than fetching from a table 🙂
Good luck for your project 🙂
September 4, 2017 at 8:51 am #72839having another look round before i attack the little
sub-project i’ve made to study this – googling gets
me back to that page, at:
https://www.juce.com/doc/classPopupMenu#a0888091ddab0f599bb9d2fab28153f6b
at ‘enum PopupMenu::ColourIds’ box, where there is ‘backgroundColourId’
and other definitions for text etc.also found a forum question at:
https://forum.juce.com/t/how-to-make-a-popup-menu-background-transparent/10312/6
which seems like a funky idea: transparent menu with coloured text hehebut that comes under ‘look and feel’, which i have no experience of.
nor do i yet grasp the notion of classes and editing them.
(just a little extension of our discussion; i’ll see what i can come
up with so far later on today – just googling a bit atm)
-nb: at least we now know what those entries for show(0,0,0,0) are now.
i conclude that 0 allows whatever is needed, with no user definition.
when i just put (15) there, it gives me a reasonable item height, and
seems to work, so that must be allowed – will have to look further at that.aagh forgotten how to read this stuff:
https://www.juce.com/doc/structPopupMenu_1_1LookAndFeelMethodsaha: JUCE examples. there appears to be something here:
https://github.com/audioplastic/Juce-look-and-feel-examples/blob/master/JuceLibraryCode/modules/juce_gui_basics/menus/juce_PopupMenu.hSeptember 4, 2017 at 8:59 am #72840void setLookAndFeel (LookAndFeel* newLookAndFeel); //============================================================================== /** A set of colour IDs to use to change the colour of various aspects of the menu. These constants can be used either via the LookAndFeel::setColour() method for the look and feel that is set for this menu with setLookAndFeel() @see setLookAndFeel, LookAndFeel::setColour, LookAndFeel::findColour */ enum ColourIds { backgroundColourId = 0x1000700, /**< The colour to fill the menu's background with. */ textColourId = 0x1000600, /**< The colour for normal menu item text, (unless the colour is specified when the item is added). */ headerTextColourId = 0x1000601, /**< The colour for section header item text (see the addSectionHeader() method). */ highlightedBackgroundColourId = 0x1000900, /**< The colour to fill the background of the currently highlighted menu item. */ highlightedTextColourId = 0x1000800, /**< The colour to use for the text of the currently highlighted item. */ };
-
AuthorPosts
- The forum ‘Programming’ is closed to new topics and replies.