at_script icon indicating copy to clipboard operation
at_script copied to clipboard

Possible to define mouse hook *after* default action?

Open ConstantinMaier opened this issue 6 months ago • 1 comments

Hey,

this is such a great plug-in - it's already enabled me to do so much. Thanks for creating this!

I’ve come across the following challenge: When hooking into mouse clicks, it seems you can only define what happens before (or instead of) the default action. However, it doesn’t appear possible to define what should happen after the default action. Is there a way to achieve this? And if not, would it be possible to consider adding this as a feature in the future?

Here’s my use case: In a script of mine, if the user moves a certain layer type to another index in the layer stack, other connected layers are supposed to automatically move as well.

Currently, I’m working around this by hooking the mouse event with Atarabi.mouse.hook(). Inside the hook, I save the current layer indices and then, before returning to the default action, I schedule a task with app.scheduleTask(). This task runs after the default action has finished (since scheduled tasks wait until the UI is idle), where I then check if the layer indices have changed. While this works, it creates some unintended side effects, since a scheduled task is triggered on every click - including clicks in UI panels, etc. - so it’s not a very stable solution.

My question: Is there an easier/more robust way to define behavior after the default mouse action, or perhaps a way to hook into mouseup events instead of mousedown? If not, would it be possible to expose such functionality in a future update?

Hope this makes sense! Again, thanks so much for your work on this plug-in - it's made a big difference for me.

ConstantinMaier avatar Jun 23 '25 17:06 ConstantinMaier