Popup Menu Experiment

Home Forums General Programming Popup Menu Experiment

Tagged: ,

Viewing 17 posts - 1 through 17 (of 17 total)
  • Author
    Posts
  • #12829
    lfo2vco
    Participant
    • Topics: 26
    • Replies: 162
    • Total: 188
    • ★★

    I have been playing with Atom’s demo popup menu demo, basically to incorporate this function into my panel. However whilst not getting the result I hoped for, I stumbled upon the attached…

    It actually answers my brief in an unexpected way : )

    However I was wondering if it is possible to constrain the position of where the menu pops up (currently a bit random)? Possibly also the size of the menu.

    Attachments:
    You must be logged in to view attached files.

    Here is some noise I organised into an acceptable format:
    https://soundcloud.com/lfo2vco/a-dark-crystal

    #12832
    atom
    Keymaster
    • Topics: 159
    • Replies: 2945
    • Total: 3104
    • ★★★★★

    There are 4 parameters to the show() method in your example they are all 0 (all is default), but you can:

    int show(int itemIDThatMustBeVisible = 0,
                  int minimumWidth = 0,
                  int maximumNumColumns = 0,
                  int standardItemHeight = 0)
    
    #12833
    lfo2vco
    Participant
    • Topics: 26
    • Replies: 162
    • Total: 188
    • ★★

    Cool… thanks Atom, I’ll continue to experiment.

    Here is some noise I organised into an acceptable format:
    https://soundcloud.com/lfo2vco/a-dark-crystal

    #12834
    atom
    Keymaster
    • Topics: 159
    • Replies: 2945
    • Total: 3104
    • ★★★★★

    Also this example is a very bad one. You shouldn’t show a popup menu right after you dismiss the previous one. You should show one menu and then add SubMenus to it, not show other PopupMenus after the click (they will show up on in the place of the click, so it might be a bit random).

    Instead try using addSubMenu() method, it will look and feel more natural.

    #12838
    lfo2vco
    Participant
    • Topics: 26
    • Replies: 162
    • Total: 188
    • ★★

    Yep, I was aware it was a bit odd. As I say it was kinda stubbled upon rather than designed.

    Sub Menus will not worki in this context as I need to make a selection in both the Bank and Patch ( it’s linked to a msb/lsb thingy ). I was originally aiming to have two buttons one for Bank, one for Patch; each with its own popup menu. Ideally scripted into the same method along with the msb/lsb script.

    However for the life of me I could not create a second menu that did not display the contents of the first… and that’s how I arrived at the above kludge. : )

    Here is some noise I organised into an acceptable format:
    https://soundcloud.com/lfo2vco/a-dark-crystal

    #13066
    lfo2vco
    Participant
    • Topics: 26
    • Replies: 162
    • Total: 188
    • ★★

    OK, got there in the end…

    So what we have now is a Popup Menu that allows selecion of a Patch via a Bank. It displays both the selected Bank and Patch numbers in a uiCDLabel. Then it sends a Patch Change message to the Kiwi- 3P followed by a Tone Edit Buffer Dump request.

    This might be a useful method for someone else to use with their synth. So I have attached an abridged version of the panel to this post.

    Question to Atom: Can the font size and background colour of the Popup be change? If so what would the code be? If not no problemo : )

    Attachments:
    You must be logged in to view attached files.

    Here is some noise I organised into an acceptable format:
    https://soundcloud.com/lfo2vco/a-dark-crystal

    #13094
    atom
    Keymaster
    • Topics: 159
    • Replies: 2945
    • Total: 3104
    • ★★★★★

    I don’t think it’s possible at the moment. The PopupMenu does not inherit the Component class that allows for changing colours, and the only way to change colours in the PopupMenu would be to create a custom LookAndFeel object and give that to the PopupMenu, and at the moment i believe it’s impossible in Lua.

    #13095
    lfo2vco
    Participant
    • Topics: 26
    • Replies: 162
    • Total: 188
    • ★★

    No problem, I had a feeling that might be the answer : )

    I have noticed that if you export a instance of this panel, during launch the popup becomes activated (before launch is complete). In some cases this causes the instance to crash. Mac OSX 10.6.8 and OSX 10.7.5.

    I have tried this with your original Popup Demo and the result is the same.

    Here is some noise I organised into an acceptable format:
    https://soundcloud.com/lfo2vco/a-dark-crystal

    #13104
    atom
    Keymaster
    • Topics: 159
    • Replies: 2945
    • Total: 3104
    • ★★★★★

    If i get pushed by more then 3 people to do that i’ll implement that, it’s not a big deal it just needs some simple code, but someone has to do that.

    Also it would be possible to create a general purpose LookAndFeel implementation (everything in JUCE is based on the LookAndFeel class), that can be used to change the L&F of any component.

    #13469
    lfo2vco
    Participant
    • Topics: 26
    • Replies: 162
    • Total: 188
    • ★★

    OK, so I got the Popup Menu working and doing what I want. So now I am thinking of expanding the options available on the Popup Menu, but there is already a lot of script to perform the single function it currently has. I think if I add more it will be totally confusing (to me).

    So the question is can I have one method for the Popup Menu, then have separate methods for the function it will call? I guess the Popup would send a result to each method on which it would act. How is this done?

    I have been looking at Atom’s Dialogue Windows Demo and I can see some stuff like:
    comboBox = window:getComboBoxComponent("myCombo") going on in the ‘windowCallback’ method and modalWindow:setModalHandler(windowCallback) going on in the ‘showWindowWithCombo’ method. I’m guessing that is performing the functions I would require.

    Here is some noise I organised into an acceptable format:
    https://soundcloud.com/lfo2vco/a-dark-crystal

    #13470
    atom
    Keymaster
    • Topics: 159
    • Replies: 2945
    • Total: 3104
    • ★★★★★

    It really depends on what you want to do with the menu. The result of the menu selected by the user is numeric, so you need to decide in Lua based on that number what will happen next.

    You can wrap that in a method sure. If you want you can wrap the whole menu creation process in a method, passing it an array of choices and handler functions for each numeric option. In Lua functions are variables and can be held in tables so you’re golden. But like i wrote it depends on what you want to do.

    #13471
    lfo2vco
    Participant
    • Topics: 26
    • Replies: 162
    • Total: 188
    • ★★

    Hi Atom, OK lets say the Method ‘myPopupMenu’ returns a result of ‘6’ and the method ‘toneSelect’ has this in the script:

    if ret == 6 then
    	firstLabel:setPropertyString ("uiLabelText", "A1")
    	secondLabel:setPropertyString ("uiLabelText", "6")
    	blah = 0x00

    How do I get the ‘6’ from ‘myPopupMenu’ to ‘toneSelect’?

    Here is some noise I organised into an acceptable format:
    https://soundcloud.com/lfo2vco/a-dark-crystal

    #13472
    atom
    Keymaster
    • Topics: 159
    • Replies: 2945
    • Total: 3104
    • ★★★★★

    Well i don’t know if i get the question but basicly

    toneSelectMenu = function()
        m = PopupMenu()
        m:addSectionHeader ("Select a tone")
        -- add some other items
        return m:show(0,0,0,0)
    end
    
    handleTone = function(toneIndex)
        if toneIndex == 1 then
            -- tone 1 selected
        end
    
        if toneIndex == 2 then
            -- tone 2 selected
        end
    end
    
    main = function()
        -- the toneSelectMenu() method will return the chosen index
        -- the handleTone() method will decide what to do
        handleTone (toneSelectMenu())
    end
    
    #13473
    lfo2vco
    Participant
    • Topics: 26
    • Replies: 162
    • Total: 188
    • ★★

    Sorry for the misunderstanding. Please bear with me and I’ll try to explain more clearly.

    If the Popup Menu is in one Lua Method, can I put the function in a different Lua Method? Hopefully the attached image will help. : )

    OK, been thinking some more about this…
    ‘myPopMenu’ method would end with ‘toneselectToRun()‘, and I’m guessing something like ‘myPopupMenuResult = MemoryBlock ({6})’.

    • This reply was modified 8 years, 9 months ago by lfo2vco.
    Attachments:
    You must be logged in to view attached files.

    Here is some noise I organised into an acceptable format:
    https://soundcloud.com/lfo2vco/a-dark-crystal

    #13478
    atom
    Keymaster
    • Topics: 159
    • Replies: 2945
    • Total: 3104
    • ★★★★★

    YOu can as i showed, your methods return numbers, and any method in Lua can take numbers (or any other type) as a parameter so:

    ret1 = function()
       return 1
    end
    
    ret1 = function(param1)
       console (param1)  -- will print the contents of the param1
       console (ret1())  -- will print whatever ret1 method returns 
    end
    

    A few links for Lua functions tutorial:
    http://lua-users.org/wiki/FunctionsTutorial
    http://www.lua.org/pil/5.html

    #13484
    lfo2vco
    Participant
    • Topics: 26
    • Replies: 162
    • Total: 188
    • ★★

    Cheers Atom, it is starting to make sense now… I need to go away and try a few things out.

    Thanks for pointing out the lessons on Functions, once I get get my head around them I’m sure it will open up a lot more possiblities. Something to read on the way home tonight eh!

    Here is some noise I organised into an acceptable format:
    https://soundcloud.com/lfo2vco/a-dark-crystal

    #13909
    lfo2vco
    Participant
    • Topics: 26
    • Replies: 162
    • Total: 188
    • ★★

    YOu can as i showed, your methods return numbers, and any method in Lua can take numbers (or any other type) as a parameter so:

    Indeed, it works perfectly. I was expecting something more complicated, but I am relieved that the execution is beautifully simple. Cheers Atom.

    The Kiwi-3P Editor panel is getting very close to completion. I still have a few functions to add to the menus, however most of the methods I require already reside in other functions that are already finished. So hopefully it will be mostly copy and pasting.

    Here is some noise I organised into an acceptable format:
    https://soundcloud.com/lfo2vco/a-dark-crystal

Viewing 17 posts - 1 through 17 (of 17 total)
  • The forum ‘Programming’ is closed to new topics and replies.
There is currently 0 users and 55 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