HISE Logo Forum
    • Categories
    • Register
    • Login

    panel + setControlCallback. How?

    Scheduled Pinned Locked Moved General Questions
    3 Posts 2 Posters 140 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.
    • Dan KorneffD
      Dan Korneff
      last edited by

      I'm probably doing something stupid.... can we use the value of a panel to trigger a function?
      I have a simple example that sets a label to the value of a panel, but it's not working:

      const var buttonPanel = Content.getComponent("buttonPanel");
      const var Label1 = Content.getComponent("Label1");
      
      buttonPanel.setMouseCallback(function(event)
      {
          this.data.hover = event.hover;
      
      	if (event.clicked)
          {
      		buttonPanel.setValue(1.0 - buttonPanel.getValue());			
          }
      	
      	this.repaint();
      });
      
      buttonPanel.setPaintRoutine(function(g)
      {
      	if(buttonPanel.getValue() == 1.0)
      	{
      		g.setColour(this.data.hover ? Colours.blueviolet : Colours.blue);
      		g.fillRoundedRectangle([0, 0, this.getWidth(), this.getHeight()], 6);
      		  
      		g.setColour(Colours.whitesmoke);
      		g.drawRoundedRectangle([0, 0, this.getWidth(), this.getHeight()], 6, 2);
      
      		g.setFont("Oxygen", 16);	
      		g.drawAlignedText("ON", [0, 0, this.getWidth(), this.getHeight()], "centred");	
      
      	}
      	else
      	{
      		g.setColour(this.data.hover ? Colours.orangered : Colours.red);
      		g.fillRoundedRectangle([0, 0, this.getWidth(), this.getHeight()], 6);
      		  
      		g.setColour(Colours.white);
      		g.drawRoundedRectangle([0, 0, this.getWidth(), this.getHeight()], 6, 2);
      		
      		g.setFont("Oxygen", 16);	
      		g.drawAlignedText("OFF", [0, 0, this.getWidth(), this.getHeight()], "centred");
      
      	}
      
      });
      
      
      
      inline function onbuttonPanelControl(component, value)
      {
      	Label1.set("text", buttonPanel.getValue());
      };
      
      Content.getComponent("buttonPanel").setControlCallback(onbuttonPanelControl);
      

      What am I doing wrong?

      HiseSnippet 1171.3ocuW8uaaaCDlJwZKRaEaEXO.D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KLrXpFCwZt4VXcJ9bmOjMIzw9THYjVMF2IX42Rh0daVluYYVem3n4KE90QGMyT.iLl0MnbXZwqQ5.TBKGTyxKJP77Y1GKDzBEIroPGY2X.KgPztCoDt93UwUZgaJt1yNqHtDjPTT.o2EW.oe68fjoneEB78WY.WVQELQvzqtAiYssEFvRpUVavrZfLgqmWdst6tVSkMaslGdqqMEtO1tKW6Gtd7tyZvKVA8eMdWrj3irOav.7k2BvVwt8O8faDVYy5F+afR1FFCOmoi4Xsi8ESh5giG7ADIRrF2z1i0fFWSkaXjMLSOPFjJ7m3uEFaZjsVXrYtQRDyOV8F+r1ZyJo6kpAwjLcabG6yMxzl4sx11Mp2fDgaG+FeeCU7DD6q2mC1Be9xsvmmtE97UagOOaK744agOe8C5i4OL43IZUTVaBpn6YoOoZYcljgUYoUjj+B9pC+iA
      

      Dan Korneff - Producer / Mixer / Audio Nerd

      Christoph HartC 1 Reply Last reply Reply Quote 1
      • Christoph HartC
        Christoph Hart @Dan Korneff
        last edited by

        @Dan-Korneff you need to call changed() after setvalue() in the mouse callback.

        Dan KorneffD 1 Reply Last reply Reply Quote 1
        • Dan KorneffD
          Dan Korneff @Christoph Hart
          last edited by

          @Christoph-Hart <3 yup... that works like magic :)

          Dan Korneff - Producer / Mixer / Audio Nerd

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

          21

          Online

          1.7k

          Users

          11.7k

          Topics

          101.9k

          Posts