Home › Forums › General › Programming › Popup Menu Experiment
Tagged: Lua, Popup Menu
- This topic has 16 replies, 2 voices, and was last updated 10 years, 5 months ago by lfo2vco.
-
AuthorPosts
-
September 3, 2013 at 2:34 pm #12829
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-crystalSeptember 3, 2013 at 3:07 pm #12832There 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)
September 3, 2013 at 4:15 pm #12833Cool… thanks Atom, I’ll continue to experiment.
Here is some noise I organised into an acceptable format:
https://soundcloud.com/lfo2vco/a-dark-crystalSeptember 3, 2013 at 4:22 pm #12834Also 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.
September 3, 2013 at 5:20 pm #12838Yep, 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-crystalSeptember 8, 2013 at 2:03 pm #13066OK, 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-crystalSeptember 9, 2013 at 3:49 pm #13094I 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.
September 9, 2013 at 5:15 pm #13095No 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-crystalSeptember 9, 2013 at 8:55 pm #13104If 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.
September 22, 2013 at 10:15 pm #13469OK, 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 andmodalWindow: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-crystalSeptember 22, 2013 at 10:59 pm #13470It 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.
September 22, 2013 at 11:22 pm #13471Hi 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-crystalSeptember 22, 2013 at 11:41 pm #13472Well 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
September 23, 2013 at 12:40 am #13473Sorry 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 10 years, 6 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-crystalSeptember 23, 2013 at 9:30 am #13478YOu 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.htmlSeptember 23, 2013 at 2:02 pm #13484Cheers 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-crystalOctober 6, 2013 at 3:37 am #13909YOu 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 -
AuthorPosts
- The forum ‘Programming’ is closed to new topics and replies.