Best Way To Reset Labels?
Hey there everyone,
I'm looking into ways to have labels display values within a ui_control callback and then reset to their original label. For example, "Freq".
So far, all I've been able to come up with is using a for loop to create a timer, of sorts, that resets the text after the UI control has been set for a short period of time. The problem is that the amount of time it takes for the loop to complete seems to be inconsistent. If I actually move the knob, the label resets relatively quickly. If I simply click the knob and its value stays the same, the label seems to take longer to reset to its original text. Very strange.
I'm hoping someone might have a better solution than a for loop within the ui control callback.
Here's my compiled test code.
{ Compiled on Fri Jan 28 14:09:06 2022 } on init make_perfview set_ui_height_px(100) set_ui_width_px(700) declare $i declare ui_knob $test_knob(0, 1000000, 1) declare ui_label $test_label(1, 1) set_control_par(get_ui_id($test_knob),$CONTROL_PAR_POS_X,100) set_control_par(get_ui_id($test_label),$CONTROL_PAR_POS_X,0) set_control_par_str(get_ui_id($test_label),$CONTROL_PAR_TEXT,"TEST") end on on ui_control($test_knob) set_control_par_str(get_ui_id($test_label),$CONTROL_PAR_TEXT,$test_knob) $i := 0 while ($i<=1000) if ($i=1000) set_control_par_str(get_ui_id($test_label),$CONTROL_PAR_TEXT,"TEST") end if wait(10000) inc($i) end while end on
Best Answer
-
Check out the example by EvilDragon in this older thread (post#6): https://www.native-instruments.com/forum/threads/ui_text_edit-on-listener-move_control-problem.322542/
1
Answers
-
Check out the example by EvilDragon in this older thread (post#6): https://www.native-instruments.com/forum/threads/ui_text_edit-on-listener-move_control-problem.322542/
1 -
Ah ha! Yea that's exactly what I was looking for. Thank you!
So, to sum up, EvilDragon says to setup a watchdog timer for each label. From what I gather, the %timer array would have an element for each label that needs the timer.
Here's the revised test script (in the Sublime KScript Editor) with this working functionality.
on init make_perfview set_ui_height_px(100) set_ui_width_px(700) declare const $RESET_TIME := 2000000 declare const $RESET_WAIT := (RESET_TIME / 1000) - 500 declare timers[1] declare ui_knob test_knob (0, 1000000, 1) declare ui_label test_label (1,1) test_knob -> pos_x := 100 test_label -> pos_x := 0 test_label -> text := 'TEST' end on on ui_control (test_knob) test_label -> text := test_knob timers[0] := ENGINE_UPTIME wait(RESET_TIME) if (ENGINE_UPTIME - timers[0] > RESET_WAIT) test_label -> text := "TEST" end if end on
0 -
And for the knob init callback, we can add :
set_control_par(get_ui_id($test_knob),$CONTROL_PAR_HIDE,$HIDE_PART_VALUE)
Sorry, I don't find the Code Block _
0 -
heya
I've got some reactive/resetting labels laid out as below and haven't had any issues. Of course the number of timers in the array will depend on how many labels you need, and $UIWaitTime can be as long or short as you like - 150000 works well for me. Using this method, your wait time of 1000 is imperceptible on my end, so you may find it needs a couple of extra zeroes!
on init declare %timer[9] %timer[0] := 0 %timer[1] := 0 %timer[2] := 0 %timer[3] := 0 %timer[4] := 0 %timer[5] := 0 %timer[6] := 0 %timer[7] := 0 %timer[8] := 0 declare const $UIWaitTime := 1500000 end on on ui_control ($Chor_slider) inc(%timer[6]) set_text($Chor_label,get_engine_par_disp($ENGINE_PAR_CHORAL_MIX,-1,2,1) & " %") set_engine_par($ENGINE_PAR_CHORAL_MIX,$Chor_slider,-1,2,$NI_INSERT_BUS) wait($UIWaitTime) dec(%timer[6]) if(%timer[6] = 0) set_text($Chor_label,"Chorus") end if end on
Results have been consistent for me! :D
0 -
Categories
- All Categories
- 19 Welcome
- 1.3K Hangout
- 59 NI News
- 662 Tech Talks
- 3.5K Native Access
- 14.5K Komplete
- 1.7K Komplete General
- 3.8K Komplete Kontrol
- 5K Kontakt
- 1.5K Reaktor
- 345 Battery 4
- 760 Guitar Rig & FX
- 391 Massive X & Synths
- 1.1K Other Software & Hardware
- 4.8K Maschine
- 6.4K Traktor
- 6.4K Traktor Software & Hardware
- Check out everything you can do
- Create an account
- See member benefits
- Answer questions
- Ask the community
- See product news
- Connect with creators