Hi Vincenzo,
It looks like you’re running into a common quirk with onDraw and mouse events in After Effects’ ScriptUI. The mouseup event can indeed be a bit finicky in AE, particularly when it’s tied to custom image updates like yours.
The key issue here is that After Effects sometimes treats the mouseup event differently depending on whether the mouse has moved during the click. If there’s even a slight drag, it might not register the mouseup properly.
To work around this, you can ensure the mouseup is captured reliably by tweaking the event handling. Instead of directly relying on mouseup, try combining it with click (which generally fires after a mouseup in AE):
myButton.addEventListener('click', mouseEventHandler, false);
The click event often provides more consistent results in this context and can serve as a catch-all for when mouseup doesn’t behave as expected. You might also consider using a combination of mousedown and mouseout for specific state resets if needed.
Hope this helps!
Best,
Nir-Vana