popup menu actions? (how?)

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

Tagged: 

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

      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’).

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

        hi 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.

        #72811
        Puppeteer
        Participant
          • Topics: 16
          • Replies: 185
          • Total: 201
          • ★★

          There’s a pop up menu example in one of Atom’s demo panel’s I think.

          The Puppeteer
          http://godlike.com.au

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

            ok, 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)

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

              possibly…>>
              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.
              #72816
              spk77
              Participant
                • Topics: 0
                • Replies: 11
                • Total: 11

                This seem to work for menu item text color:

                Tone_params:addColouredItem(1, "toneName1 00 00/VSTindex1", Colour(0xff21c630), true, false, Image())

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

                  oh 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 ? ;-D

                  i’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..

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

                    oh 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 ? ;-D

                    i’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#abca9890f63f22575c190c0115a1f3acf

                    and 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…

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

                      Maybe it is possible, but I don’t know how to use this info :)…
                      https://www.juce.com/doc/classPopupMenu#a0888091ddab0f599bb9d2fab28153f6b

                      Public 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…

                      #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.
                        #72821
                        human fly
                        Participant
                          • Topics: 124
                          • Replies: 1070
                          • Total: 1194
                          • ★★★★

                          looking 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 🙂

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

                            Here’s a gif:

                            Attachments:
                            You must be logged in to view attached files.
                            #72824
                            human fly
                            Participant
                              • Topics: 124
                              • Replies: 1070
                              • Total: 1194
                              • ★★★★

                              that 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.

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

                                For 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…

                                • This reply was modified 6 years, 7 months ago by spk77.
                                • This reply was modified 6 years, 7 months ago by spk77.
                                #72832
                                human fly
                                Participant
                                  • Topics: 124
                                  • Replies: 1070
                                  • Total: 1194
                                  • ★★★★

                                  i 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?

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

                                    Now 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.

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

                                      ok, labeltext, got that. i shall try this in a bit and get back.
                                      need food !
                                      thanks for your help!

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

                                        i 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?

                                        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 🙂

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

                                          having 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 hehe

                                          but 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_1LookAndFeelMethods

                                          aha: 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.h

                                          #72840
                                          human fly
                                          Participant
                                            • Topics: 124
                                            • Replies: 1070
                                            • Total: 1194
                                            • ★★★★
                                             void 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. */
                                                };
                                            
                                          Viewing 20 posts - 1 through 20 (of 25 total)
                                          • The forum ‘Programming’ is closed to new topics and replies.
                                          There is currently 0 users and 88 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