1. IMPORTANT:
    We launched a new online community and this space is now closed. This community will be available as a read-only resources until further notice.
    JOIN US HERE

How to link ui_slider and ui_label

Discussion in 'Scripting Workshop' started by Claudiosky90, Mar 3, 2014.

  1. Claudiosky90

    Claudiosky90 New Member

    Messages:
    16
    Hi everyone, i'm new in this forum and i think it's very interesting.

    I would like to add in my kontakt script a label that shows the information about the % of Reverb Size (in the InsertEffects panel).
    The following code shows the value of RV_SIZE only when i push apply but, it isn't updated.

    Code:
    
    declare ui_label $ppot1(0,0)
    set_text($ppot1,get_engine_par_disp($ENGINE_PAR_RV_SIZE,-1,1,1))
    
    
    Thanks for help!
     
  2. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Use that set_text line in "on ui_control" callback of your control.
     
  3. Claudiosky90

    Claudiosky90 New Member

    Messages:
    16
    Ok i succeed:
    in the callback i wrote
    Code:
    set_control_par_str(get_ui_id($ppot1),$CONTROL_PAR_TEXT,get_engine_par_disp($ENGINE_PAR_RV_SIZE,-1,1,1))
    
    Thank you very much for help!
     
    Last edited: Mar 3, 2014
  4. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    You didn't need to do that, you could just copy that set_text() line over.
     
  5. Claudiosky90

    Claudiosky90 New Member

    Messages:
    16
    i can't succeed when i put the set_text command in to the "on ui_control".
    the debugger says to me that the command is not a ui_control.
    I'm sorry.
     
  6. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    No way.

    Code:
    on init
        declare ui_slider $Size (0,1000000)
        declare ui_label $Text (1,1)
    
        $Size := get_engine_par($ENGINE_PAR_RV_SIZE,-1,1,1)
    
        make_persistent($Size)
    
        set_text($Text,get_engine_par_disp($ENGINE_PAR_RV_SIZE,-1,1,1))
    
        message("")
    end on
    
    on ui_control ($Size)
        set_engine_par($ENGINE_PAR_RV_SIZE,$Size,-1,1,1)
        set_text($Text,get_engine_par_disp($ENGINE_PAR_RV_SIZE,-1,1,1))
    end on

    That should work.
     
    • Like Like x 1
  7. Claudiosky90

    Claudiosky90 New Member

    Messages:
    16
    Ok, i tried and it work in both cases.
    last detail: i'd like to show the Percentual (%) beside the value, it's possible?
    because i found this command $KNOB_UNIT_PERCENT, but is just for knobs.
    Thanks
     
  8. Big Bob

    Big Bob Forum Member

    Messages:
    606
    Use this for the 2nd line of the callback handler:
    Code:
    set_text($Text,get_engine_par_disp($ENGINE_PAR_RV_SIZE,-1,1,1) & " %")
    
     
    Last edited: Mar 4, 2014
  9. Claudiosky90

    Claudiosky90 New Member

    Messages:
    16
    Perfect, now it works!
    Here it is the result:
     

    Attached Files:

  10. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Set the text alignment for first and third label on top to center :)
     
  11. Claudiosky90

    Claudiosky90 New Member

    Messages:
    16
    You are perfectionist! ;)
    Code:
    set_control_par(get_ui_id($ppot1),$CONTROL_PAR_TEXT_ALIGNMENT,1)
    
    Done.
     

    Attached Files: