christophhart / HISE

The open source framework for sample based instruments
http://hise.audio
Other
1.04k stars 122 forks source link

[Bile Titan] Key press callback for components executes three times per key press, making it unusable #511

Closed aaronventure closed 6 months ago

aaronventure commented 6 months ago
HiseSnippet 953.3ocsV0saaaCElzwJX1qsXsnO.D9JGz.C6tt1gNLjt3XWXjkTgojhcWAsHkMmoHEDoZiaQuaOO6Un21Wi8Fr2fsCoriT9AooFXN.Alm+324vO9QGlqi4FiNGgacxxLNBemfnkJ67gyoBEZxAH78BNhZr7bRoo8WlQMFNCgwa8RmAbqlH+m+Yu8oRpJlWYBgdsVDy+UQpvVYM7EGJjxwTF+DQZsnexKlDqUC0RcAfmsB5ixnwKny3GScg0H.g2dDSX04QVpkafX1WyVFMW+NUY7uVXDSkb2hAnHnPklQCmKjrv08pAgvMCq57sJ67GFbjfIN2d0D367NHUYTeFfabSPZvWAjv0fTyRHc+fn3bQlsxiCOeavDEbfjPgQccnTFKpwtMBFpgHT1dozE7w4vhyyn6S62eWB7uc9o1sgwswRdKMmjQUbI4mIqSjxXgNSc6.cksytDHIeJIEpXqPqHK3KCyAPMjJkSgyot5o+wNs+P6VPILZIuWVtPY6ZmKL8lwsc6HXc1g7HRG3uGQFolITbmiSyr.KnakKWg5ILi0wEF3PPMiS1izYhgPA2Omz4XskPKKUhKFRrOndc.38w19FomgaO7x36x.10M0l.SKrVnstvH3PkdZ4DnzKLGdb+0ShRS2xs57wlVA3m+JUW+rB.L4xtRRtVeNXkqkRd9051cUJ+lRrqpHcJOeWnYkE7yCD3ZWj.u8si.GWNkpEnVMQIruJiuZ8Xsj4HltueU5NZ0X1Q7WgPHTqm1euUz9HofwyQBlSVp5T.46f5pLnSmb.0RWWKnrvVkwysBWGgOf+VPEp7JUqfC3lEVcFHnLTmloUNPfaVty2c8ENGKxuwa62XzYHb.1sSKW+ETsruysC29h745EwXW5FsaG3XZnTAiI4gZivczUSY8Sf.bVj389l9CO7ud4e+9+buz5huHTJ8r5ZwlhjDwYdUyDgL0XAfMIEDSQ3GDbpgSX7DZgzRLKf5HEpEb1IZe7nqJDARfZVgjZuntn6AfUNb.ttXjSvQAMxx5f5qPrr+MJVdag38CBE134WOFabMXDnP+efwUOwb2fQII7XaE.aFL922z2S9Ba+uoKrB0rinvQui4cbQZD7xZL2IpBzaiiD1vQjKW2eMoLhqX9E+K7YkyAt03UNGr1IP5hy0uIt79q6QruwaAvjx+lcK3GO.qICt5cVfrKdSb7EK0UR7waZhe+ll3S1zD+gMMwmtoI9rMMwe7Kmn6m77KEVcZ40FD5nvQdMVLdjhBLPOaE8erWubWD

a46275bfd90aa394c830d676d7ba3c218f60a5d6

macOS 14.4.1

christoph-hart commented 6 months ago

Yeah, you need to return true in the callback or otherwise it will be executed many times.

However this is super annoying, another user ran into the same problem a few months ago plus I had to debug the issue just to find out that it's a usage error and not a bug in HISE, so I've changed the way it works to be less opaque going forward.

So you need to call an additional function setConsumedKeyPresses() which "pre filters" whether the callback should be executed and returns true or false automatically based on the provided key press list.

I've updated the docs to reflect this too:

https://github.com/christophhart/hise_documentation/blob/master/scripting/scripting-api/scriptpanel/setkeypresscallback.md

https://github.com/christophhart/hise_documentation/blob/master/scripting/scripting-api/scriptpanel/setconsumedkeypresses.md

aaronventure commented 6 months ago

Nice one. Do you think tagging the commit as breaking would be a good idea?

christoph-hart commented 6 months ago

Thought about that, but I've just throw a script error that will complain if you use setKeyPress() without calling the other method before, so this should be a hint enough for the changed behaviour.

Also it's not a hard breaking change that requires you to actually change something, just add another function call for each key press you assign.