Author Topic: [PJSR] newInstance - how to find a target image?  (Read 6935 times)

Offline bitli

  • PTeam Member
  • PixInsight Guru
  • ****
  • Posts: 513
[PJSR] newInstance - how to find a target image?
« on: 2014 January 12 04:33:12 »
I am implementing the 'newInstance' functionality in a derivative of PropagatePreviews, based on the explanation at
http://pixinsight.com/forum/index.php?topic=2177.msg14242#msg14242.

Works fine, but I would like to find a workaround for the limitation on applying the operation directly on an image.  Because I am just creating previews, there is no reason to really create a new instance of the script. I just need to know on which image (if any) the button is released. If it is on an image, I can copy the previews there (no need to update the history). If it is on the background, I can call newInstance.

I tried to find if there is a way to catch the mouseRelease of the tool button and find the image from the location of the mouseRelease. Not much success yet.  Do anybody have a clue?

-- bitli


Offline Juan Conejero

  • PTeam Member
  • PixInsight Jedi Grand Master
  • ********
  • Posts: 7111
    • http://pixinsight.com/
Re: [PJSR] newInstance - how to find a target image?
« Reply #1 on: 2014 January 14 10:09:30 »
Quote
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.
Juan Conejero
PixInsight Development Team
http://pixinsight.com/