detect mouse down LUA

Home Forums General Programming detect mouse down LUA

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #10861
    KALYWAY
    Participant
      • Topics: 9
      • Replies: 23
      • Total: 32

      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
      end

      is there anyway way to process ?

      thanks ,
      kalyway

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

        It 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)
        
        • This reply was modified 10 years, 9 months ago by atom.
        • This reply was modified 10 years, 9 months ago by atom.
        #10872
        KALYWAY
        Participant
          • Topics: 9
          • Replies: 23
          • Total: 32

          thank 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 ….

          KNOB COMBO

          if any idea welcome !!

          thanks
          kalyway.

          • This reply was modified 10 years, 9 months ago by KALYWAY.
          • This reply was modified 10 years, 9 months ago by KALYWAY.
          #10876
          atom
          Keymaster
            • Topics: 159
            • Replies: 2945
            • Total: 3104
            • ★★★★★

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

            #10877
            zeoka
            Participant
              • Topics: 73
              • Replies: 466
              • Total: 539
              • ★★★

              If 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.
              #10880
              atom
              Keymaster
                • Topics: 159
                • Replies: 2945
                • Total: 3104
                • ★★★★★

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

                #10890
                KALYWAY
                Participant
                  • Topics: 9
                  • Replies: 23
                  • Total: 32

                  HELLO MORE DETAILS :

                  my first attempt is to set 2 methods :

                  combo to knob :

                  comb to knob METHOD

                  combo to knob lua

                  AND knob to combo :

                  knob to combo meth

                  knob to combo lua

                  the result is when i attempt to drag the knob HANGING

                  hanging lua

                  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 )

                  condition mouse down

                  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.
                  #10906
                  Hecticcc
                  Participant
                    • Topics: 25
                    • Replies: 160
                    • Total: 185
                    • ★★

                    Try 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.
                    #10908
                    zeoka
                    Participant
                      • Topics: 73
                      • Replies: 466
                      • Total: 539
                      • ★★★

                      You can’t do your first method !
                      The second is too complicated for me

                      Please 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.
                      #10916
                      KALYWAY
                      Participant
                        • Topics: 9
                        • Replies: 23
                        • Total: 32

                        link.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 :

                        MOD LIST only way

                        REALLY THANKS
                        KALYWAY.

                        #11328
                        zeoka
                        Participant
                          • Topics: 73
                          • Replies: 466
                          • Total: 539
                          • ★★★

                          Hi 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.
                          #11340
                          zeoka
                          Participant
                            • Topics: 73
                            • Replies: 466
                            • Total: 539
                            • ★★★

                            tried 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 tried

                            otherwise no problem with the sliders the method is working

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