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

Set exact line for text in label

Discussion in 'Scripting Workshop' started by Aderre, Jun 8, 2014.

  1. Aderre

    Aderre Member

    Messages:
    33
    Hi, I would like to know if there's a way to fix a text part to a concrete line in a label. What I want to get at the end is something like a label that constantly shows when an effect is bypassed or not, and would like to do it with the kind of label with scroll, so not with many labels only with one.

    I already tried with add_text_line, but that won't stick, it rather logs all the changes. I would like the Equalizer: ON/OFF to be constantly displayed under the Evelope: ON/OFF. Thanks!
     
  2. Big Bob

    Big Bob Forum Member

    Messages:
    606
    How about something like this:

    on init
    ``message('')
    ``make_perfview
    ``declare ui_label display (1,2)
    ````display -> text_alignment := 1
    ``declare !EnvTxt[2]
    ````EnvTxt[0] := 'Envelope: Off'
    ````EnvTxt[1] := 'Envelope: On'
    ``declare !EQTxt[2]
    ````EQTxt[0] := 'EQ: Off'
    ````EqTxt[1] := 'EQ: On'
    ``declare ui_switch Envelope
    ``declare ui_switch EQ
    ``UpdateDisplay
    end on

    on ui_control(Envelope)
    ``call UpdateDisplay
    end on

    on ui_control(EQ)
    ``call UpdateDisplay
    end on

    function UpdateDisplay
    ``set_text(display,EnvTxt[Envelope])
    ``add_text_line(display,EQTxt[EQ])
    end function


    You will need to use Nil's editor to compile the above source but, I've also attached a little demo instrument (.nki) with the above script pre-compiled so you can see if this is more or less what you are trying to do.

    Rejoice,

    Bob
     

    Attached Files:

    • Like Like x 1
  3. Aderre

    Aderre Member

    Messages:
    33
    This is exactly what I was looking for! Many thanks!

    A last question, when I refresh the ui with any button, the list automatically jumps to the bottom, is there a way so the list in the label starts from the top, or that is impossible as of now? (It is a label with a scroll option)
     
    Last edited: Jun 9, 2014
  4. Big Bob

    Big Bob Forum Member

    Messages:
    606
    I don't think I understand what you are saying. What do you mean by 'refresh the ui with any button'? Can you illustrate this with a simplified example?

    Generally speaking, whenever you write or re-write to a 'scrollable' label, you must re-write all lines not just the last one. The first line must be written with set_text (which clears the label of old text and writes the first line) and the subsequent lines should be written with add_text_line in the order you want them to appear.

    Rejoice,

    Bob
     
  5. EvilDragon

    EvilDragon Well-Known Member

    Messages:
    19,938
    Nope, can't do anything about it.