Home › Forums › General › Programming › detect mouse down LUA
Tagged: mousedown detect LUA methods
- This topic has 11 replies, 4 voices, and was last updated 10 years, 9 months ago by zeoka.
-
AuthorPosts
-
July 15, 2013 at 10:27 pm #10861
hello , i want to detect a mouse down event in lua editor , from a knob
example : setmodulatorvalue only if mousedown on it etc …..V_HALL1_ER_REV_KNOB_TO_COMBO = function(mod, value)
V_HALL1_ER_KNOB_val = panel:getModulatorByName(“vh1_ER_revbalKNB”):getModulatorValue()
if mousedown ……( i cannot find the command to type after if )
then
panel:getModulatorByName(“vh1_ER_REVBAL”):setModulatorValue((V_HALL1_ER_KNOB_val),false,false,false)
end
endis there anyway way to process ?
thanks ,
kalywayJuly 15, 2013 at 11:49 pm #10869It is possible, though i notices i might have missed a piece of code to make it work fully, i’ll upload the new nightly and the code to get it is:
-- -- Called when a modulator value changes -- @mod http://ctrlr.org/api/class_ctrlr_modulator.html -- @value new numeric value of the modulator -- myMethod = function(mod, value) s = panel:getSlider("modulator-1") if s ~= nil then ownedSlider = s:getOwnedSlider() if ownedSlider ~= nil then console ("slider") if ownedSlider:isMouseButtonDown() then console ("\t button down") end end end end
panel:getSlider(“modulator-1”) that part is missing now, and i need to add it.
You could do
c = panel:getComponent("modulator-1") c:isMouseButtonDown()
but it will always return false, this is because the real slider is a child component inside the CtrlrComponent class.
You could also go the hard way and fetch those chlidren components using getChildComponent(index) methods, but this might be too complicated (that would work now) for example:
myMethod = function(mod, value) c = panel:getComponent("modulator-1") if c ~= nil then slider = c:getChildComponent(0) if slider ~= nil then console ("slider") if slider:isMouseButtonDown() then console ("\t button down") end end end end
BUT the call slider = c:getChildComponent(0) assumes that the real slider is child component 0, and it does not have to be that always, to be 100% sure you’d have to go through all the children of the component using getNumChildren() method.
All the Component class methods are described in the JUCE api: http://rawmaterialsoftware.com/juce/api/classComponent.html
also using the magic what() call you’ll get a list of all the available method for example:
c = panel:getComponent("modulator-1") what(c)
July 16, 2013 at 1:14 am #10872thank for your infos !
i have tested your methods , also the hard method , but do not work for my stuff
i just want to synchronize dragging knob / and changing combo , when i drag the knob the combo change his content to the new content (i have attached a method in the knob modulator value change : knob >>> set combo ) but if i attach same reverse method in the combo box : combo>>>set knob , the ctrlr crash , due i think to an infinite loop created between combo and knob , i can only attach one method in the combo box OR in the knob cannot attach 2 methods (one to combo and one to knob ) , this is the reason i have to trigger mousedown in combo or in the knob , but ctrlr crash also
i have to find another way to synchronize them ….if any idea welcome !!
thanks
kalyway.July 16, 2013 at 9:01 am #10876Crashing does not happen without reason.
If you used one of my suggestions first please show us witch one.
Statements like that “i have tested your methods , also the hard method , but do not work for my stuff” are not helpful. So present your method, it can be done it’s a matter of implementation.July 16, 2013 at 10:00 am #10877If you want just sync two mods , you can apply “link modulator to modulator property” and
select “modulator value” or “value” and select the modulator to link for ONE and for the other apply a “called when modulator value change” lua script where you
“control” the first modulator.
Normally the two modulators will be synced in both way…- This reply was modified 10 years, 9 months ago by zeoka.
July 16, 2013 at 10:38 am #10880Also infinite loops will crash ANY program (or hang it), it’s better to crash then hang i think. With Lua you get direct memory access, there is no sandbox etc. if you corrupt the memory you crash the program.
July 16, 2013 at 7:09 pm #10890HELLO MORE DETAILS :
my first attempt is to set 2 methods :
combo to knob :
AND knob to combo :
the result is when i attempt to drag the knob HANGING
the second attempt is to add mouse down condition for setting the combo content from the knob , i want to cut this infinite loop causing the hanging…i have added the last method suggestion by atom , more difficult but the others do not work (the second method return false in anyways )
but same result , no synchro values , hanging ……..
@ZEOKA , could you explain more , with code examples or with pictures , how to apply “link modulator to modulator property” in the property editor i can not select anything ….i cannot find links from a modulator to another modulator
how to process ?
THANKS TO ALL.
kalyway- This reply was modified 10 years, 9 months ago by KALYWAY.
- This reply was modified 10 years, 9 months ago by KALYWAY.
- This reply was modified 10 years, 9 months ago by KALYWAY.
- This reply was modified 10 years, 9 months ago by KALYWAY.
- This reply was modified 10 years, 9 months ago by KALYWAY.
- This reply was modified 10 years, 9 months ago by KALYWAY.
- This reply was modified 10 years, 9 months ago by KALYWAY.
- This reply was modified 10 years, 9 months ago by KALYWAY.
July 16, 2013 at 11:10 pm #10906Try setting it to 0 before assigning it a value, i had a similar problem with the menu uiListBox component.
Normally you won’t even see the “glitch” it makes.
- This reply was modified 10 years, 9 months ago by Hecticcc.
July 16, 2013 at 11:47 pm #10908You can’t do your first method !
The second is too complicated for mePlease Try what i suggested before ..that’s working for sure
i’ve attached a working panel
To have access to the properties i talk you must before “refresh property lists” in “view” to select them in the modulator property right panel.
- This reply was modified 10 years, 9 months ago by zeoka.
- This reply was modified 10 years, 9 months ago by zeoka.
Attachments:
You must be logged in to view attached files.July 17, 2013 at 1:53 am #10916link.panel
BIG THANKS TO ZEOKA (and the others )
I HAVE FIXED THIS with your example , but the only way i have found to set the properties is to process with the modulator list , the property editor on the right give no choices to select , modulator name , or “modulatorValue” target
there is a blank , i have to go to modulator list , and show visible columns concerned , and copy and paste , the items i want to add :REALLY THANKS
KALYWAY.July 27, 2013 at 6:14 pm #11328Hi i’ve this one :
step = panel:getModulatorByName("1-ArpStep1"):getModulatorValue() glide = panel:getModulatorByName("1-ArpGlide1"):getModulatorValue() accent = panel:getModulatorByName("1-ArpAccent1"):getModulatorValue() slstp = panel:getComponent("1-ArpStep1") slagl = panel:getComponent("1-ArpGlide1") slacc = panel:getComponent("1-ArpAccent1") slider1 = slstp:getChildComponent(0) slider2 = slagl:getChildComponent(0) slider3 = slacc:getChildComponent(0) stp1 = CtrlrMidiMessage({0xF0,0x3E,0x10,0x00,0x20,0x00,0x02, 0x47,((glide)*8)+((step)*16)+(accent), 0xF7}) if slider1:isMouseButtonDown() then panel:sendMidiMessageNow(stp1) end if slider2:isMouseButtonDown() then panel:sendMidiMessageNow(stp1) end if slider3:isMouseButtonDown() then panel:sendMidiMessageNow(stp1) end end
problem : glide is a button so isMouseButtonDown() may be not working like a slider
may be i can play with the button state property ?
i’ve tried to change the childcomponent number..- This reply was modified 10 years, 9 months ago by zeoka.
July 28, 2013 at 2:11 am #11340tried to search the good index (-1 to 20) no success
serched with what() and this uiImageButton has isMouseButtonDown() and some other things i’m not sure but i triedotherwise no problem with the sliders the method is working
-
AuthorPosts
- The forum ‘Programming’ is closed to new topics and replies.