How to trigger label callback on enter/return but not on focus change?
-
I thought I could handle this with a keypress callback but it doesn't work.
The callback still triggers on focus change. Another way is to do the action I want in the keyPress callback directly (which is fine) but the label's value still doesn't update until a focus change occurs.
I also tried manually triggering it by calling
loseFocus
but that doesn't work either.HiseSnippet 912.3ocsV01aaaCDlxIJHRasXEX+.D5mTFJLricbSZvv5hS7lQaRLpSK12JnoNYQXIRAQpznUz+y6eP2QI4X4lfzVCT8ACduw6Q28bm7jLICTJYFwx8phTfX8y1SKD5ngQTtfL9Th0isOmpzPlWkpSJRoJEDPrr15uLJrb1lT97e+wIzXpfAqTQHuSxYvq4Ib8JsSd4q3wwinAvU7jFd2+kiYRwPYrLGwyV1cHoT1B5b3BpwsV1j+lphHV+l8A62i0O34A6u+AGMfQG.GERCC61Kne+AGdT2dGQ6e3.nyADqcNKfqkYS0TMnvK8DYPwzH4GDUI3cbEeVLXD5RlhYtRMYXDONXxxhihPr1dxpR0VUkpe09bd.+V8qJY+RoAuUQzrnY05gfT2uCHY0.RaWAomXOkkwS0qrXvyOYOVfcvPJ1aZBkJeIsraYOThdHzsSnKfQYnvsQ3OnSmm4g+r2wttX+Qo8tll48Z5LHtq2u6sLx4fdnLIUJPA+mVY9oXLUmZqLlE5LY7PZb7Lrw5KEU1p0atetHlK.uvbASykBuuvEe1xL7LDDw4vdtez0AMpjwP6zLNl5J8G69I20SsJOABdETLICKLfx+iKfhgx.3Edc68IStW48RutEoKwiObMl6xjxC8pjZyUijrbE19EyQ.43jA57LwwtNtN5HtpMqzRfuAT6cbi2sKjZ3Rge48g306KMEFdu1pKFwP18Z1LTk8PA5KxSlAYMKgFGQRz5Lyc91XlrJBPCGkhwBt9xTnVdjLNvv3LmuKOlTyfvSuc7oTM0Psq0g9kBYZtANVmBWiKSpH5N1mBpEZYZou0jBbIltz5ipGCJaoDNl5csqZujaHV1VlrVXNr.O7AdfNxHDYQHQ.edj1H4illMe41HmcPwOa1REhHaJ+eWaukQW0Rpcsu7lh43KtFtAulcruBT3a1cmTwcDxf7Xpd8EGlUp0Fvd1ZSqlIRghqKZtx86XaRmGbax2JDeh8DtlEc+Xr08fQra9i.i06fej8Ygg.SuBfaaO5e1zEtekz+FYtlKleNUmwM7nKxSlhrCFXl8EPrxvaZYXzUxcLxlJvTPDTJ7Y7o1XWirUswtKMRRnrL46YUSpls76VpAwjnjf4feNFk85RJmdaVmSvO57dFa8q5NAt+lFXuMMv9aZfGroANXSC74aZfG90Cz7eB9ybsLoZrgPNexYkq6rrNSPQFXIak7+.773pt
And the bug with label text watcher broadcaster not working is still present.
-
@d-healey Could the property
updateEachKey
be of any help to you? -
@ustk I don't see how. I just want to trigger the callback when I hit enter.
I could roll my own complicated solution where I store each entered character in a variable and then process it when enter is pressed but that seems like a lot of work for something so simple.
-
keypresscallback object has a "isFocusChange" property
-
This post is deleted! -
Was the keypress callback a crucial part of your script or was it a work around for getting the value to print on ENTER?
-
@Chazrox I was using it to try and get around the focus behaviour.
-
@d-healey oh, In that case, I think I got it to work (Print value on ENTER and nothing else right?).
try this?
const var Label1 = Content.getComponent("Label1"); Label1.setControlCallback(onLabel1Control); Label1.setConsumedKeyPresses({keyCode: 13}); inline function onLabel1Control(component, value) { Console.print(value); Label1.set("text", ""); }
HiseSnippet 880.3ocsU0taSiDEclzZTi2kUKR7.XkeEPUUNMskBHzlsIs6FAsMhvhPnUBMY70wip8LV1iK0KBo8sh+tOR6a.6crcpcJgETD3HE464buybl49gmjn3PZpJgPseQdLPn+n0zboNXX.SHIiGQn+j0orTMj3TBcTdLKME7HT5F+lAf1dSRwy+9KGwBYRNTCQHuTI3vyDQBcM5jAOUDFdByCdgHpg26MXLWIGpBUYnd1vxkDy3WvlCmwLt0xh76rz.B89V6tqO+PW2C62eeWFquGisWOn+CA+C74669PWuY66h+NfPu0wdBsJYplogTBcyiTd4SCTuUVtAuTjJlEBFidjo3NWBehJzybDMnjgAhPuIKtnRI3pLo9Zaixqs6ZcpvSbMd802OWP3TGQyKPZqkk2FKIudMkmaC4sBIQaHoMKkzcrlxSDw5ZFid9AqwRLa5yv7TSoT5Ko0GnVCUnGR8NQrKfSRPiqin6Atta6f+cuGaai4pTsykrDmmwlAg8bdhyhHmC5gpnXkDM51ojtCFS4a6jZnk5DU3PVX3LLI2UIK4pvuouoYQf2Sg7II3IAR69tKf7gJO3QN85+diXDxPgDb7yjbsPIctw50kuPNaiJNLCtm86raaVXUHrSbh.0YI9isaWuyc6ngqzc11oiQ8u211twFblRCmK6VrRHmyMo78WIWkhBgjURaZIR9+BrqLKZFjz7bXbDS6KWKY84qkZVpyKSYMbTIGKE5yiA4mqAfTkmw29iwiXZlo.rBC8KFRzBiDnifKw1+xxw1VifzKzp3BeqxF3XGcA6sqJVKt6IBrjbKqx7.4pqmP7O+4f7ZiWO3sBOcv0.+8kCB.w7fFSZFMX17EySZeKD3iFTeToSE+0RSdLXkiY1x57qxmiGdSpuXpC4S6svtZkWVHSubqtYfXEAlyVp+xzCISE57lCL+l0++0Jw6XMQn4AqVisVgFwL62CMVM071VG66Cbcs.2z5jW88YDI44pLsPN+TlNQf0TVmkEMEqL3.t6RIDZ5YnsLU2k1tFayMvTP5UX7Q7ohrmwlVQ1aAIIhwSTugW1oZlKuUABpIYQwUa7ionsSORQ2ay64H7yDugyWdo9j.2ccCr+5F3dqaf6utAdv5F3CV2.O7KGn4q3+ZlVEU11PHmN43hQeT5wRFVAVTsR9O.LwdkQA
*Edited because I noticed it would trigger callback if you clicked out after ENTER without clearing the text.
in this example I input text, press ENTER, value prints, I click out and callback is not executed. I click in and out of the text input field just to show it doesn't execute.
-
@Chazrox Type in the label, then click on the UI outside of the label, for me that's firing the callback.
-
@d-healey yeah, that'll drive you nuts. haha Sorry. Thought I had it.
-
I got it to almost work here, if I'm understanding the issue correctly, high chance I'm not
HiseSnippet 1356.3ocsW80aaaCDmJIJHVaFXEXXOsGz7VKrQCBR555JVZ2biS7PPye7l65VQPP.sDkMQnHEjnSpWP.F1mj8QYutuB6w8IXu2G5NJJYQYK2UDzp.3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f0tjKfdGzE+pYuKI4boHBX5zbVnuDYp15YkFSc7HJT.bMacP.8xosW7a31SlNv8x1pXOLa1bA5RpubTQeHx1iHzgiL5X4aaOXXdeI0VED7ZkTLiNjGlRjZ1.2NfDHQAvNoO8WMZq4QsQFTtVYJmlckQY8E7FTtsvfxvfY34KlimunMURBKX50ux6uUxKjdOSwWjGUsV1jhqsHJVyNqFy6RN9v9u5epfi4heq7cqZqtrbQA6+P19sHBWlU29pe3upfUe9fO82mwyoRdWDCKRHcrYC.WWYVh9BCVBOkY4eFWAK0YsehsLdhK10mFDPhgU1Et1KrhbusaGgU5MnXluBMeGlPusB+wLrrbCupt7yT.2kTpKSUmjbnYoIleEv6rtfeao3sr6QkdipliKUAGgabdevwrucnt8dPTwSVPvUr69Kue9PAzOJFKo7gGhkwTHwx9nwg8gjUOBr5bUgKPl0RpiQ5wapFq7.8Ib+zAuFdxTtkZrUlxsxUhBwdwhy7zUPTecxZoR.NwS+vrZ1GpF6tEJsphoeND9Xoy77JOUyA7d2Tfe4ME38uo.+paJvGbSA902TfO7+Gn5aYexXoHTerAgNr2dokjsr1iqZYJMaE8e.G1gEK
The issue now is the callback is triggered immediately when the label is 're-interacted' with
-
@rglides What is Enter here? I don't see it declared anywhere
if (key == Enter ...
Edit: Actually that keypress callback doesn't look valid, you should only get one parameter which would be
event
. -
@d-healey Enter is for the setConsumedKeyPresses right? Guessing I'm wrong but I thought the method was setConsumedKeyPresses("Enter") and then if key == Enter, do I not need to do this? seems to work for me
-
@rglides said in How to trigger label callback on enter/return but not on focus change?:
Enter is for the setConsumedKeyPresses right?
Not unless you define it. Your if statement is currently the equivalent of
if (key == undefined ...
-
@rglides Ha! yeah, I changed it to if (Label1.get("editable")) and it works, ok little lesson learned. Still, this works, almost
-
@rglides said in How to trigger label callback on enter/return but not on focus change?:
if (Label1.get("editable")
The label is always editable isn't it?
-
@d-healey Sure, but for some reason it has allowed clicking outside of the label and not triggering the callback
-
@rglides said in How to trigger label callback on enter/return but not on focus change?:
@d-healey Sure, but for some reason it has allowed clicking outside of the label and not triggering the callback
It's still triggering it here. Add
Console.print("test");
inside the if statement, you can remove all the update panels stuff, it's just complicating the picture. -
@rglides uggggh, ok, HISE has defeated me yet again, my logic was to start with an if statement to see if the callback could be avoided, so I thought I had it. Turns out the callback just won't trigger at all regardless of the if statement, until the label is re-interacted with (or when hitting enter) so I have proved useless again. But I tried, and it was fun to feel like I figured something out, briefly
-
@rglides said in How to trigger label callback on enter/return but not on focus change?:
I tried, and it was fun to feel like I figured something out, briefly
You've done no worse than my attempt :)