Set the clicked Color of the Panel
-
I have a panel button, I can set the hover state color, but I can't figure out how to set the clicked color.
if(this.getValue() == 1)
doesn't seem to work here. Any ideas?const var BtnPnl = Content.addPanel("BtnPnl", 60, 50); Content.setPropertiesFromJSON("BtnPnl", {"width":80, "height":80, "allowCallbacks": "Clicks & Hover"}); BtnPnl.setPaintRoutine(function(g) { if(this.getValue() == 1) { g.setColour(Colours.skyblue); } else { g.setColour(this.data.hover ? Colours.deeppink : Colours.whitesmoke); } g.fillRect([0, 0, this.getWidth(), this.getHeight()]); }); BtnPnl.setMouseCallback(function(event) { this.data.hover = event.hover; if (event.clicked) { Engine.redo(); } this.repaint(); });
HiseSnippet 984.3ocsV8uaaaCDlxIJqRacXEXO.D9OFjAxLryZ6JRVP6hiSq2VRLp6xJvvPAiDsEgkHEDoSlQQem6aP6chRQxMFYsFXBF1h2ceje2OoGmqB4ZsJm338pkYbhy23NYozDOHlIjjQGSb9V2SYZCOmZEczxLlVyiHNNa8bTfi21jhm2+ziXILYHuVDgbgRDx+CQpvTKc7y9cQRxIrH9qDoMr9gOaTnRNPknV.7YK2djLV3b1L9YLzrVtDmcFFILp7IFlgqAaNREsbRr5Zo09KDZwkIbbQexDXirhIChEIQiq7UMg3r83ZOeKqm+8tmJhD2HuNB7cEJn0HZFCbZcWTp+W.kbZPossT5AtSByEYlZMHe9Z2QRHgLkAg5lTwZKok+VtCTfERS2T1b9I4vhaPDrWud6Rgu5bfuODt0F5Urb5QF4XYB8PZERVTzXljmDz1pp8tzGC.eDhqxFMGYVFO2H3Z3XR+sImeVC.us80hHSb68eBfrcLWLK1Ttfkjntd.78kPJV2deZ6AIB3M5OPeg5Jdd62g7y2tUEGDjMLuTsvHj7foKjgFgRFLqi+a88DSCLwBc2YbyErjE7fNzCOj1uiuGnzaFB2VUEX+Q2UOe4kfgvY38NeOeOdhleaqK1zHlg0MF4D8ozJ7QbdVlPNmt+MhtNV.E.op4k6pOrUSg57WxCMA+M3yvmJV9WXXInSsfWTDaB57OnWac8F99opEZdUvp144WAIAL.PgmOkqGRKTaWcPgIXfhZQ0MDi17HLDAtu2P4LHt1MmGoB5bfWwC5DHpa18bdFlD.CrBQkVtVQIpRdlxvOWFTjW7gM3SUMc5Z0gkT4pjDd9ZUiCJxuKfAxEoWxy2EJlw7ZkgPmzpsm6740dFZqvaXnRNRJLmmwKWehJIBa6v2ucyLorEAd6OGcLjUv96RY0sLfri4WACHsc6dtGy0yMprBaSyTRbGb9JSg16WMK.6JIB3numqsDg7uDGWmeANqk3K6AuTz2A63NiKmCaa9ZJY0NPbJ2pcfvb5aMOBlDphVjvLqNdDuGnTAjTVYlDN2QpElkMum3KXlYu6bl4mKEef6XgILd8br0Z3Hjt9+fik2zbe2gSmBiEpI31tm75M8Zk+ii2Nyb1oLSt.KTNaQ5DXfUHGNcITJowZlVXIqccObMFAlvkQEK9.7TprOt1oTY+JkjTVXt5Mg1VQ7tr6UHA3jr3paO3+P.qo8IEsm.N2dc6QRgqUeSXH59+HzEsdL6sAX9oM.yC2.LOZCv73M.yOuAXdxchA+GM+5BiJ01N.BFOrXNkiyPICprJpBIeDvp0f7T
-
@Steve-Mohican You need to communicate between the mouse callback and the paint routine that a click has happened. You can do that by setting a data property as you have for hover, what I've done here is use the panel's value.
What's with the
Engine.redo()
?HiseSnippet 997.3ocsVEtaaaCDlxNpsxacXEnO.D9GEx.YF1YscEoKncwwY0aKIF0cYCnXnfQh1hvRjBhzI0nnuy8Mn6NRqH4VmhAiUg.Gw6tOxOdGuOpwEpHtVqJHdAuZYNm38s9SVJMICRXBIYzQDuuy+Dl1vKnNSGtLmo07XhmWyeEM3ErCw97gmcHKkIi3UlHjyUhH9eHxDlJqie9uKRSOlEyekHqVzO74ihTxApT0BfOM86QxYQyYy3mxvvZ3S7t0vXgQULwvLbMwamCUwKmjntR5h+bgVbQJGGzmLAlHm4iUowHiQqjAIhz3wk6aMAlkwUYgltrv88OQDKt1dU136sNnUHpmO7ZrN8ZtF85Wmd8pQuMPIuZTZGGktm+jnBQtoxCxmuwejDJNSYPZuNUbwRZ75l9CTPDRS2L1b9wEvfqQDtWud6Rge57zVsfTu1PujUPOzHGKSoGPKQxhiGyj7zv1NWs2k9X.3iPbkwn4Hyx4EFAWCKS1uM4rSqA3csuRDaRZu+S.jsS3hYIlUCXoopqF.+dATt0s2m1dPp.di9.5KTWxKZ+djesbSkcgfpg4kpEFgjGNcgLxHTxvYcZ8tVAhozPShP2cF2bNKcAOrC8fCn86zJ.7FLCw6NhE59mtqd9xKf.gEI38sB3oZ9mGqcJiYFV2DjRzmQKQGy444B4b59Wa5pDAT+yTyWMmajUctA1TviwsK3aJzk7RdjI70PVB9qbB9KLQF1oxvKrYyvN+CBzlrpxUmnVn4kI2pjE+RnngILJ77oatCnV2tQO0FRUb5xcfKlHrTYorML6NccOPxL.1qCkyfxEt8TgtzxZSaAOGqpfKmQzoqtWxYpRdpxvOSFZKzsfI3ScMc5F8gmQKToo7hM5FUgJ9R.CkKxtfWrKzcfmSJCDZMWue2+l62qKGE4ZYpEnRNRJLmkyk2jHEYUeF71eN5HnTghDqrU02A1NheIn35jLB7OhqmaT41XyxURbF7tsw58tkBJXqMQ.xF2w2ctg7VXu38yvZsDeYO3EayKLi2Z7JgcWGbcKq2FiRkq2FCB+elnFHmphWjxLqqwhWrrxATHVSXCEujZgYY8Kd9eS38+JEum+XgIJYybrwF3HTt9ZvwUWWcW+gSmBJEUDbG+i+6uN2MQbBuyNgYJD3AkSWjMATth3vpKgiRXifWC7HqabObLlAlvkw1AeDdV4rON1aky9kNIYrnB0ahbse3Eh2wZA3jz9s.AvGk.io8I1VR.meut8HYvcyuIJB29+.zEsYL6sEX9ws.yC2BLOZKv73s.yOsEXdxWDC9YQ+xBiJy0N.FFOzpS44MTxfSV1Sgj+EmBM4xA
-
@d-healey Oh bro, you are a lifesaver! Thank you so much!
Engine.redo()
is for redo action. Also I will be using its brother too,Engine.undo()
. (Undo/Redo). -
@Steve-Mohican
Engine.redo() is for redo action. Also I will be using its brother too, Engine.undo() . (Undo/Redo).
I'd put those in the panel's control callback rather than the mouse callback. It won't make a functional difference though.