I just need to know on which image (if any) the button is released.
This is not possible with current PJSR versions. Since script dialogs are application-modal windows, they cannot interact with PixInsight workspaces, so there's no way you can receive a GUI event from an image window or a preview in a running script.
You can, however, know how your script is being executed and, in case it is being executed on a view, you can identify the target view. This functionality is provided by the Parameters core JavaScript object. I suspect this is not what you want, but anyway here we go:
Boolean Parameters.isGlobalTarget (read-only)
This property is true if the current running script has been executed in the global context. Otherwise, the script has been executed on a view.
Boolean Parameters.isViewTarget (read-only)
This property is true if the current running script has been executed in the context of an existing view. Otherwise, the script has been executed globally.
View Parameters.targetView (read-only)
If the current running script has been executed on a view, this property is a reference to the target view. If the script has been executed globally, this property returns a null view.