Panel keyPressCallback and focus
-
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.uzdbDXdSD3yb1mFPGIebj3SSUfFiHe7vdtIo27SPu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srd1d6.k8598xBhPfMlHTTcNydGxYPyyoc+45rCQdphGahxYMhAh+2hyud77Q2ZP9AmSCTgiE7hsBIzdgp7Rfxc94CK5AF8QNPubnwBj3yfKIzaMH.N645iecd3VWGhNJoNF5a9l2mY5JyLld76YLc0bL8WTuOGSWalwT0+GL8xO1BdlGOHIBql7se5G7lo.NFdhGboeTESRUCx+f3+ydP30kh2yostu0h43bEvQ3rm2EbL6Yz20oU2tDe0XBtfyte66l2LakdkduCvPqdP904vj9cf2n4SzuDP2B.HydN8MMoiqoGqi.cflXLC9a3Slx55w1YJqOToUeruf+R+zy70OT+NFI.mXleiBWmCziQitixwoV0ZV8oAzW56qW9KA2gVLlUtAXV8FfYsa.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 :)
-
-
@ulrik said in Panel keyPressCallback and focus:
@christoph-hart this was what I needed, thank you
I think I was a little bit to entusiastic before
It works great as long as the panels not are childs of another panel.
As usually organise my components in containers (panels) and to get this focus thing to work, I have to have all panels at the same level.
Is there a way to get pass this limitation?
HiseSnippet 2036.3oc0Y0uaaajDmz1LWn50qs.2eb2+sU3PAErrrjSaZfUSpjkkKLbrifkSPCJtqXM4Jo0ljKK4J6Hb0.2iVdQNf6Q3dCta1OH4JYYGWm1hVAaCsyNe7a1Y1Y2Y8fTlOIKikZY6dxrDhk8ezY3rX9jdSvzXq820xthy4jYIo.WV6LKAmkQBrrsW8aDya6tlk7y+8q2AGhi8IkjrrdEi5SdNMhxKoNnyAzvv8vAjSnQFb+4c12mE2iExlBXYUmlVIX+ywiIGgErshik8C5GP4rzgbLmjYYu1NrfYCmvtLVw+qnYzSCIhAsrFBJRQdOVXf.wBpV8lPCCFj6yYVfVFTtBrpZE3O6bHMfVPubk3ikSfJkvb8vdk4g2pyAuVlvqoA7VBjrMfzZJH8INC8SoI7xYD34Cb1OlSRGggkcSnn30Zk+8G3ziAbDyaDgOmrWJLnPBuG2rYcD7mZsqTAV5y3nKvonA3XRXF5onbIGS3cCC6whRXwv3LupRVpJDSK2fiA98FMM1mSYwdiqU4eVwcbiQPfFD0SETyZbIkOoaXxDbAkwojY0QMarUMPatUbgeniPd7IzrFAXNtAm7FdiPR7X9DzyPMqUwEzLn5LBWoiBUg+go3HbJMlHTEvRPJ9xtgzwwjfS.srfRqijiAm64Leb3NrowAYdMqUGU0G7xTRfvAcuphKrZPtYyd4DJ+VsHXgWgCmR7pc2M4hqBSvY6w7mlUqvLGKDlDbLwmiiGGR7VlpaApdq5nVfVuxHZcXuclKbQt.rtLjIrpbTC+Pp+4j.zO9iHEAvni0q9WiKArbKQaDaZFYWHuGrxBKAskgXCMnUqTuJUDxxHRmUwsqHm7Bgz4ZaAartop9VXHZCCH+ZkRjBlkCCo5LlveBrFRBTF7JiHfVOrov91dBeUuBrLfNuIx8aupAjQ3ogJxUqoCvt5.xla59MjXRJNDc.Y1.QM1d3vvSgJetabSezgwCFzatvH6zypgDQwTxXDnIvnsUNhXpFTUJTOouVqhY.KO8BTmf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