1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

UI Button setting Value of Slider

Discussion in 'KONTAKT: Sampling, Programming & Scripting' started by jfino, Jan 12, 2018.

Tags:
  1. jfino

    jfino Senior Member

    89
    50
    Jan 10, 2017
    Hello everyone!

    Quick question:
    I want to assign a value to a slider(s) using a button.

    The slider controls several parameters.
    In the below example its controlling the Volume.

    When I press the button, the value for the slider updates but
    the parameters that the slider controls don't update.
    How do I make it update?

    Thank you!!
    Jimmy

    Code:
    on init
        declare ui_button $Button1
        declare ui_slider $slider1 (0,1000000)
    end on
    
    on ui_control ($Button1)
        $slider1:=500000
        {I could just put the set engine par here but imagine I have loads of sliders
        and each control several parameters, also there's several buttons with different values}
    end on
    
    on ui_control ($slider1) {slider1 of many}
        _set_engine_par($ENGINE_PAR_VOLUME, $slider1,-1,-1,-1)
          
    end on 
     
  2. henrik242

    henrik242 Member

    16
    4
    Oct 29, 2017
    What might work is to write a function that calls the set_engine_par function, and then call that function from both callbacks.
     
    jfino likes this.
  3. OP
    OP
    jfino

    jfino Senior Member

    89
    50
    Jan 10, 2017
    Functions YES! That would help avoid repeat code.
    Thanks!!!
     
    henrik242 likes this.

Share This Page