Get user mouse click

Hello,

I’d like to create a tool (such as magic wand, pipet tool, etc). This tool needs an active current document.
So when the user executes my script, I’d like to :

  1. change mouse cursor (optional)
  2. get next user mouse left click

a) if the click was on the current document : retrieve document pixel coordinates and consume the click event,
b) if the click wasn’t on drawing (like if the user selects another tool, etc) : not consume user input

Is it possible from scripter ? Or from a python plugin ?
I couldn’t find any info in the libkis documentation or in other plugins, so any lead would be welcome :slight_smile:

Thanks !

No, this is not possible. You cannot make new tools using the scripting API.

Ok, thanks. It there another common way ? Like may be create a plugin in C++ ? Or it will only be a special krita build but not a sharable plugin in the end ?

Yes, you can write tools as plugins in C++: all tools in Krita are, technically, plugins. But those plugins need to be built for every platform separately.

1 Like

I don’t know if this will help with what you want to do, but I present this topic as a Python script that clicks on the mouse position.

Translated at DeepL