Panel keyPressCallback and focus
-
@Christoph-Hart Gentle bump :) any chance you get the time to fix this?
-
I tried several fixes with no luck. It seems that the focus is lost as it should but when clicking anywhere in the interface editor, the first component automatically gets it back.
-
The keypress creates an "OS error" sound, thus making this callback unusable in an end product
-
Also noticed that since a few commits, the letters are printed 3 tttiiimmmeeesss... :)
HiseSnippet 1228.3ocsVstaZbDEdVauQYoMUMR8AXp+0hJl.j3jHa01fwPkkuDjwIpsQQQi2cfcBCyrZ2YsMpxuC8QsuAsmyLfArwVsnlUBXOy4x7w2btLcyzQ77bcFwK3rwobh2W62arxjzJgITjC1m38M9GyxM7Lpao8Fmxxy4wDOu0+EbAufMH1m+5m2iIYpH9rkHj2qEQ7iDiDlYq18MGJjxNrX9YhQyY8KdyAQZUKsTW.3Yc+ZjTVzP1.9ILzr07IdOpcrvny5YXFdNwai8zwi6knuT4r+8hbw4RNJTmzCBja4NZYLhXbURqDgLt6z+24DHJcmwBq6Xguy+XQr3l0mwFeqUAclGyyGdqsH7VeA3Ued3UaN3sDH4MGj1vAom52KJSjZloAwyW4efBNb5y.Zedn3rkr1O462RCVnLUGwFx6jAB23Q3KqUqBE9p7tkJUB39bC8BVFMUIyo+H8CS8jEG2ko3xvMs+TeyJz5nmvWkqThdmm6wuFS864feeD1Rbe9PsOVMma98i3WfFZA3l.dr5pubck5qyngoTgxB0xk9iRAonkcgiIyo5BiPwC6WnhLBsJbP4RAfEACp1Gx6ZJkg0tpQiN1GHZnBvWWdGnZ6smoBTJ5GZRD4UiYFV0DVdGcTArkAnawYrKOkGYbVLfaNRGwj6oKTw4g.2PqWs1jvL+d39Iu5kIBCeBBvP0TJFn3wmwuxL2dZ.wJz6aG1LBX5LdLxKAW61LKWbHeb2LHQoESJOGpilwG5y+bYpiRd1ynmAoETFUp0CoLicePh0jvoXFgVxA6Z4dqZZFPvglLL4ACiE7NRBDqJbrCTtnFvQNB2if6RePxEZ9TQLHWCe3xb9TmxuTXhRrQcHebKcrMdNcHra2qUyts2gtOWxMbKbQhxpNhkyoMd0NNRSpy41sIr7tTp0f.aZ54Yb1vcmFvSae16N8D5gs+scnet.pDP+rwsO57r.W+4OPfCtUT2qYqC60sYK.omxGouvEQIzQkFkv.dDJEmE5WuCkt3AOvTKtP07hyyMvwvfvZUtsNIWMvjrU8x6tbzzLMkqhoL0XpRq1JOkGIXxagjXdeVgzrCENT+dj+mXFjPUdRXCtEH+A244MwYWzFz1qmbxhBVex3oXMZ3zr0qKgOSSMoZ0IZC+spPaMMnkdaU86uTcXKmLsTxyVpZbPS1C4XnpXz47rJP+OYA+FCgtuK1R2+9aoO+DmHWGv4LTqNPILuE3+6aNDYRaS3s2cv9.2hyAlrFXWJOyHPH3sO+BXnpapPf+977gFcJLerkdTpVgQv6QFq1mLclA19kHfICO120BmbE7ewKF1qwSe4RQrIAE9SOBIgKFjXlph7eHzMtUnq38vg9tS5fYr53BIyr3fW71FST.GcKLsCmnoxElwyeaj+2lF+uEhO0uK1yZ4XbskfQ3.9KAFmbGlm32teeX3zL.tgeme8KyEVHtgtCNlAslvy+SJF0ClwEwwYAPVAV53sFlI4jqgxHCzCZHYE9a3Yhx5nr2Dk0mpjLhEko+TjqfEukzisq.XRYufX.bSUPlVmXKhA+7qUsFYDbgsOEEg+82Bp6VtOMVAed9J3yKVAe1dE74kqfOuZE740OnO3ckaVXzibkCvBcaa6r440VwfLKaVH4e.CLja4.
-
-
Trying another bump...
-
@ustk You need to return
true
from that function so that the system knows it consumed the key stroke. This solves problems 2 and 3.The first one is a bit more tricky because JUCE propagates the key focus by default to its first children and it's super annoying to find the spot where you need to disable this.
-
@christoph-hart Oh cool for the
return true
thing, it works...As for the focus issue, why is the callback called when clicking outside of the object anyway?
Because the focus is lost as it should when usingthis.loseFocus();
, so why would the callback be called again from a click that didn't occur onto the panel? -
@ustk it will get executed as soon as the panel gains focus and clicking on it is just one of the possibilities (Eg. Tab key cycles trough the siblings)...
This is deeply embedded into JUCE and debugging this is super annoying...
-
@christoph-hart said in Panel keyPressCallback and focus:
This is deeply embedded into JUCE and debugging this is super annoying...
please tell me it's doable
Or we can say goodbye the entire API -
@ustk it's definitely doable (probably a one line fix at the right location), but finding it is the hard thing...
-
@ustk said in Panel keyPressCallback and focus:
I tried several fixes with no luck. It seems that the focus is lost as it should but when clicking anywhere in the interface editor, the first component automatically gets it back.
This works okey
It has 5 Panels just for testing
At init, all Panels will be set to the same KPC, PR & MCBfor (p in Panels) { p.setPaintRoutine(PR); p.setMouseCallback(MCB); p.setKeyPressCallback(KPC); }
then in MCB
if (event.clicked) { for (p in Panels) p.setKeyPressCallback(""); }
and in
if (event.clicked && event.shiftDown) this.setKeyPressCallback(KPC);
HiseSnippet 1507.3ocyX80aaaCDWJIpsxaEaEXe.37CExXIN1IY8OIXXwwwoKHModwoEqurBFIZK1HSpQRkTih.rG19Jrm2CaeE1yCaeg12fsihx1xNxooAsC0.Iv7t62we7tijGcaA2mHkbgks6QChIV1erSmALUXyPLkYs61V1kbNgLHV.VYs0fXrTRBrrsm+QZ81tKXk94e95svQXlOYrHKqmwo9jGS6SUik1dy8nQQ6fCHGQ6my501bWeNqIOhm.bYdmZVwX+Sv8HGf0lMmik8MZEPUbQGEVQjV1KrEOXPmP9YLi8OiJoGGQzCpa0AbjQ7N7n.Mi0RsZFRiBZObMKs.uzdbDXdSD3yb1mFPGIebj3SSUfFiHe7vdtIo27SPu54oWsbzq.JYmiRKXnzcb53KnwpwZz74ib1koHhtXHrmmJFasl6utoSSNXASUsO9DxNBXvHDd2qVsEQv+prQoRPnWpPmhEn1XFIRh9JzPj8HpFQQM48i4LXrzqbpIk0vxv09PvdutILeEky75UozqK41qZWHQCP8LIUY0ynpvFQwg3QR5IHCVDUq5JU.u4pwHIJixwnBoJhVcupAB7YMhn8XjfiHuR4oBoRM+dFNJg3UYQzPAOl6ii1hmvBjd0.4k8AlKHAkm8zf+gDberfxtr4J.qvUUvvq1TU57bAo8at0DQIxofgoQJZWjYTU+Hp+IjfJkbAwtc4BjWLhxxRJfXW2XM22i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ziQitixwoV0ZV8oAzW56qW9KA2gVLlUtAXV8FfYsa.lO+Ff4A2.LqeCv7vqDi9mqoQhh2Oc6.HncKykt11sXXnxxTEZ8ODo3tTM
-
@ulrik that's a cool hack, however I am not sure it is safe to kill the CB from within itself...
-
@ustk Yeah it feels a bit risky, I wish it could work as it's supposed to
I could need it in a project -
@ulrik I'm waiting for a proper implementation for my current project so I won't risk a bug, the release is soon...
-
@ustk I think I've found the spot where to put that line. On the other hand, it's bad coding week, so nobody knows what I'm breaking with this :)
https://github.com/christophhart/HISE/commit/cbdab1d60823f213db4f87a81ff19edd8b927e79
-
@christoph-hart Yes, but it can only get better now, right? ;)
-
@christoph-hart said in Panel keyPressCallback and focus:
@ustk I think I've found the spot where to put that line. On the other hand, it's bad coding week, so nobody knows what I'm breaking with this :)
https://github.com/christophhart/HISE/commit/cbdab1d60823f213db4f87a81ff19edd8b927e79
perhaps more testing before commits?
-
@christoph-hart trying to build...
-
@christoph-hart So that seems to work. But can't we lose focus when clicking anywhere outside of the panel?
If not, then it's not much of a big deal since hitting "enter" works -
@christoph-hart this was what I needed, thank you
-
@ulrik Then let's hope it doesn't break Lindon's computer :)
-