HISE Logo Forum
    • Categories
    • Register
    • Login

    Redraw knob text after timer

    Scheduled Pinned Locked Moved Scripting
    3 Posts 2 Posters 122 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • whoopsydoodleW
      whoopsydoodle
      last edited by

      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);
      
      d.healeyD 1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey @whoopsydoodle
        last edited by d.healey

        @whoopsydoodle

        Peek 2024-12-16 11-47.gif

        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");
        }
        

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        whoopsydoodleW 1 Reply Last reply Reply Quote 0
        • whoopsydoodleW
          whoopsydoodle @d.healey
          last edited by

          @d-healey yes of course. Much cleaner. Thanks!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post

          15

          Online

          1.7k

          Users

          11.9k

          Topics

          103.6k

          Posts