setMouseCursor consistency
-
@tomekslesicki Not working for me with or without. Does the cursor set on the panel pass through to the child components?
A broadcaster is probably better than a timer. https://docs.hise.dev/scripting/scripting-api/broadcaster/index.html#attachtocomponentmouseevents
-
You don't need to query the current mouse position, you can just call this in the onInit callback:
ScriptPanel1.setMouseCursor("PointingHandCursor", Colours.white, [0, 0]);
It will then automatically switch to the cursor when you enter the component (or one of its subcomponents).
-
@Christoph-Hart I think he only wants it to switch on the sub components
-
@d-healey
then just call it for every sub component you need it to change.Nope that's wrong. I forgot only the ScriptPanel has the
setMouseCursor
method. Maybe it’s better to spend my time improving my skills. That way, I'll be more useful to the community. -
@Christoph-Hart I saw that comment, I loved it! That being said, if you COULD lend some of those improved skills to allow custom cursors on non-panel components, I wouldn’t have to hack around like this! ;-)
@d-healey Yeah, I want to set the cursor per component. I can get it to work as I described in the first post, but it’s not a real workable solution unfortunately. It’s strange, though, because I can get other functions to work - the Console prints just fine with the timer and sub-components nested in that panel, it’s just the mouse cursor that doesn’t like me.
-
@tomekslesicki so I went back and improved my skills and here is a possible solution that is moderately hacky:
HiseSnippet 971.3ocsVslaabCDlTVzvZSSPCPO.K7ujBDLzSGEDTDEKaWKzJGgJ2fVXDDPsKkWBuhbAWtwVnn.8bze0SPNQ8PzaPxv8gzpZUYYk18GK37hy2Lb3LbnR5vBCkJD15hYALD9qHilIzd87nbAp+wH7SHCngZlxNg0QyBnggLWDFuy2YXfKUDE+82u5HpOU3vVvBgdqj6v9A9TtdA2gc+dtu+oTW1E7o4ztU29NRQOouLBvyNjZn.py0zqXmSMpUffNiF5gvOibXswMqwZ0jViMYxyaVuUqFzwcNrcm1cZzg17Eiosa2dLsCBu6ItbsTMRS0rPXSOR5Najm7FQhCdKOjO1mYHpiFAdNgMpmG22cXVxIDgvEGtHUsSRp5aHC3t747Wjx95XA1KrHeRCWXcPp9C.R3bPpXBjdJYjihGnWHwfmGQ5KfSvIT3rIOTRzEU3OwjdRPCg9fozqYmp.h4VT9vZ0pZC+p7RKK37ITa+ApxNPxEZt3JOpvMfJX9g1eq8kYayULcO4z.o.HJu+Pi7l6Wopk887sF6arek2AHXhTUNvlKVA.pXUJ3fPldfLJj0KRAgOXapZmApkva+p1I0XgGbiGWypZeIDf0dWkWNIR3n4RgsTbtTydinbEqe0pj0uYY+OEMYxJkYvuR56yTqTrodWsNCKKhlNlopBoX+H1bEgy2kKZ1cyJZbRRm4TTJ5K352DvRoOU56ZJFLquaIFJ87.J11IEgvJcbo1SRK0NJRqkBDG1jRjDh5nX3muO.5AXdiuLyatBy+o9GS0TyclzHBhx.lRyMIS7wrO.coRtAUhbLK7ZsLHV2zRPHgm31Gmc+xTvE608HwqqitctC+8K6Nag2un6MbWMz1hf+CLB4w3W4oMTeDmjVm6Cx83iFFePv9vlNyrPAKBnJv1baxb7rD72aCNytMeFaVdh+Mmz.kFZYp9KcyBuLN86pY2ZnIwWDYJyQ4FGwMSh3+JKhKh+OLharEQbyuzHd2Mn7MNlkYw7YqMlS70iHmKm6s6NU.lGIci7o5kGRYFemJ.ZBszjAS2eQHWOK+38GvjqZqcx0lBwmRFx0NdqFiEVAFgKT+efwz48OlbxjILG8B.Vjb5OusC2uG2+ixHyXqATshaJHNOZ5HXlkCC7tvLsyTaTvzYLgtlg1jAFwDtwDeB9REV2PiSEVOSHZJ0QIeuSRqUyKJ1KlCfIQ7KtJAO8CnsWQ+7ovCbduiyxa0cLrw1ZXys0vVaqgs2VCObaM74aqgcteCMu+70QZ4zjqMHzfgmDOADiOQPgJv3pUzmQ1L0nO
So basically you just have to put your components into a small panel with the same size, then set the mouse cursor for these small panels. If you have a lot of UI elements it might be cumbersome to setup but you should be able to write a script function that does this for you (adding a panel, setting it to the same dimensions as the UI element and set its cursor).
-
@Christoph-Hart thank you, I could do it this way, but I have a ton of controls to nest like this, and editing such a project wouldn’t be very effective in the long run.
Would it be possible to either enable setting the mouse cursor for other components, or to fix whatever is causing the current implementation not to work consistently?
The script I posted in the first post works and the logic seems correct (I guess?) but I need to edit it (as described in the first post) and compile it a couple of times for HISE to register the mouse change properly.
Thank you!
-
@tomekslesicki Is it just buttons that you want to change?
-
@Christoph-Hart yup!
-
@tomekslesicki Alright, I've added a script property to the button to set a standard cursor type.
BTW, you can also change the cursor type using CSS, which is available for all components:
const var laf = Content.createLocalLookAndFeel(); laf.setInlineStyleSheet(" button { cursor: pointer; } label { background: #444; text-align: center; cursor: text; } "); Content.getComponent("Button2").setLocalLookAndFeel(laf); Content.getComponent("Label1").setLocalLookAndFeel(laf);
-
@Christoph-Hart Epic, thank you! Your skills benefit the community <3
-
@Christoph-Hart actually, the script property method works great if the buttons are not nested in panels, but doesn't work when they are. The same applies to the CSS method. Here is a minimal snippet:
HiseSnippet 851.3ocsV0sSaCCE1tPPP2fMj1CPTuBlPnz0zBSno00BLp1.pVYncGx0wkXQhcThCPEZR6QXOR6QYOB6MX63jz1DnCXUZ8hpd9+yG+cNtcCkTVTjLDgKexv.FB+TidCEJ21tDt.0YWDdEiCIQJVnYppVCCHQQLGDFO260JvKMOJ4yudaKhGQPYSTgPmJ4T1G49b0Dsca9Atm29DG1Ib+bda2rCUJZK8jw.dlyvBEPnWPNmcDQ6VICzAjHWD9kFMnuttUelU85aaWaaa6F1MpaMvp1f9a2vtessrq4XWuJsFBuvdNbkLrmhnXQH77sjNC64JuRjVfS4Q79dLsPUTOnxop2W54nOhZsn1tbOmtiZTQHHKcmz1lKss8BiC4N7w5mz9ddhAyIQjuAhKUDdyU.dU+avaJPBmCRymBoUM5QC4ApIVz34IFcDvs4.BbOkGJo9hJsC1nsD7Pn1zmbAa+PPXbDq0vxZCS3q02obY3tJRYdIIzLM1VwJkTT07MliRv4LUaoefT.BqUofWUzYnflMiXfS9x3HV63P.tU1vrRWIWn3hyOfHbxzt9NChETEWJLkhijJ1wh0Vu7MkWp7WKadaSCFLUaZ.FJ87XgS0rlVFdeAtlH1uOKbC3z6EyF6Hz5Kdetvi69jl1ux4nTzQvUGGvxjueBIJqgq4AYHDbUkvBVwHeWFwgj7rBpphRND4GZQetytDEYT5fLCUKfEp35CEdW1kvPcJIaIicYQWnjAI9lcWCG7zhu7HJHQv7Rp8J40TEcMBaf0Ub3nebE2Q4NFL+7xltL94tS1d78aZVnRK9nOlWONGeizb3XgezuYVMMvNf7n5kJEPBgxjqd25.jiupWBbW9Jrt6NSlvNAoSrGQUbQgdcZlAfsUX5TOAJh3pg4W29Or8v5d2d7Xg3pFc4Jp6zwXoofQfA8+.iY6bW1XuACXT0D.Nuw9eYVWv9.k+SxX8E6gDUHWyZOJ1uG7NEkAUW.TgHMiojdVLU1ZDgtGS3jH7a3SlwpZYblwpiLh7IzP4YzzIX8V8ESz.XRj7B3RvSwfr4TFY8gGYNiRKlp6D3ql0.qMqAZOqAVeVCrwrF3VyZfa+vAp+O.uKVI8SGaPnC6tWxJVLdOAAXfIrUze.3Aph1.
Could you please take a look at this? Thank you!
-
I'm giving this a friendly bump.
-
@Christoph-Hart I checked the latest commit, that solves it! Thank you!