Calling DELETE from script so confirmation appears over the viewer?

Im using a button showing a dialog with js functionality in the image viewer to delete the current image (and others) with the delete command. Thus calling delete from a "simple" button will not work for me.
So when i call DELETE from my dialog the confirmation dialog does pop up behind the image viewer as child of the tab that contains the image and the viewer was started from.
When i call DELETE from a simple button, the confirmation dialog is shown as expected as child of the image viewer.

function OnClick(clickData)
{
	var cmd = clickData.func.command;
	var fileNames = //comes from somewhere else but is correct
	cmd.AddLine( "Delete " + fileNames);
	cmd.AddLine("Show VIEWERCMD=refresh");
	cmd.Run();
}

Greetings
Felix

The Command object has a method to tell it which window to use as its parent. Pass that the viewer window if you want the confirmation to appear over the viewer. (Or pass it your dialog if you want it to appear over that. At least, I think that works as well.)

The Command object also has a method to feed it a list of the files you want it to work on. Another method lets you clear the predefined list, if you need to. (It usually has the selected items from a file display, or the current image in the viewer, depending on where the Command object came from.) Use those and you can then run "Delete" without appending all the filenames to the command string, which is usually preferable.

cmd.SetSourceTab(clickData.func.viewer);

Leads to "Das Objekt unterstützt diese Eigenschaft oder Methode nicht. (0x800a01b6)" (object does not support property or method). I dindnt find any other fitting method.

And clickData.func.viewer.Command("Delete \"" + clickData.func.viewer.current + "\""); doesnt do anything.

Somehow forgot about this.

Try clickData.func.viewer.parenttab.

If the argument you pass is a string then it can only be a viewer command argument as documented for the Show VIEWERCMD command.

If you pass a Command object then all commands (internal or external) can be used.

https://www.gpsoft.com.au/help/opus12/index.html#!Documents/Scripting/Viewer11.htm

Thanks, but then the confirm dialog shows up again between lister and viewer (like in my example above and the way which i dont want).

But

	cmd.AddLine("Delete");
	cmd.AddFile(clickData.func.viewer.current );
	clickData.func.viewer.Command(cmd);

now finally works (didnt read properly, thanks!)

1 Like