Redraw knob text after timer
-
I am attempting to use my knob text to display the value and then have it switch back to the normal knob text after it's been moved.
This version mostly works but the knob text doesn't update back to the proper label unless it gets a new event like hover. The console prints correctly on time but the UI doesn't update. I know there are redraw commands but I haven't been able to figure them out properly. I also was trying putting the text label draw into a LAF and then calling that but didn't have success.
Also I'm sure there has to be a cleaner way to do this instead of declaring a variable to count outside of the function. Eventually I plan on doing this for multiple knobs and would prefer to write a version that is nicely reusable.
const var MixKnob = Content.getComponent("MixKnob"); var MixInt = 0; const var MixTimer = Engine.createTimerObject(); inline function onMixControl(component, value) { MixKnob.set("text", Engine.doubleToString(value, 0)+" dB"); MixTimer.startTimer(500); }; MixTimer.setTimerCallback(function() { if (MixInt > 1) { MixKnob.set("text", "INPUT"); Console.print("hit"); this.stopTimer(); } MixInt++; }); MixKnob.setControlCallback(onMixControl);
-
Add this in your laf, no timer requried.
if (obj.area[3] > obj.area[2]) { var text; if (obj.text == "") text = obj.valueAsText; else text = obj.hover || obj.clicked ? obj.valueAsText : obj.text; g.setColour(Colours.withAlpha(obj.textColour, obj.enabled ? 1.0 : 0.5)); g.setFont("Oxygen", 12); g.drawAlignedText(text, obj.area, "centredBottom"); }
-
@d-healey yes of course. Much cleaner. Thanks!