panel + setControlCallback. How?
-
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.D9ujARMry5ZGVQPShS7lwZRLpyxFvvPAszYKBSQZHQaGih.rGf8P02ns2fsiRVVxoNYtd+vnn.2c7t6ie5NdW5Fq7gjDULwx4p4iAh0mZ2atTG1JjwkjNmRr9b6d7nwB3aQEWAIZxIyGyRRf.hk0tFknqUHo+9iWdBSvj9PgJB4ZE2GdEOhqKz18numKDsYAvU7nRm9oG0wWIaoDpIHh10tAYLyeDaHbAybrcrIVezYAbsJtmlogDhUkSTAy6EplIyN+07DdeAXDZR5gAJScakHvfXiVRqPtHna9MOgfQoaAOraFO7E1myC3K0WlOLFnEdTlOr1Y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YtQRDyOV8F+r1ZyJo6kpAwjLcabG6yMxzl4sx11Mp2fDgaG+FeeCU7DD6q2mC1Be9xsvmmtE97UagOOaK744agOe8C5i4OL43IZUTVaBpn6YoOoZYcljgUYoUjj+B9pC+iA
-
@Dan-Korneff you need to call changed() after setvalue() in the mouse callback.
-
@Christoph-Hart <3 yup... that works like magic :)