Copy link to clipboard
Copied
hello,
Is there a way to run "LrTasks.execute( command )" wait for the result and then show the plugin UI window? I tried it but it seems to be working only if I use it within "LrTasks.startAsyncTask" but the plugin UI shows immediately without a chance for me to process the result to modify the UI.
thanks
-lmora
Copy link to clipboard
Copied
Couple of things:
1. LrTasks.execute is supposed to wait for that task to complete, but be aware that some tasks might "fork" (i.e. launch another that's disconnected from the first and terminate immediately). Most GUI applications on either Windows or Mac will fall into that category. (On Mac, if you're using the "open" command as I suggested here recently on another thread, this will happen.)
If that's what's happening, there isn't much Lightroom can do.
2. You can only use LrTasks.execute within an LrTasks.startAsyncTask block, as you've pointed out. If your code looks like this:
LrTasks.startAsyncTask( ..., function()
LrTasks.execute( command )
end )
LrDialogs.whatever
this won't do what you're expecting. The LrDialogs call will occur before the LrTasks.execute call (because the execution of the function inside LrTasks.startAsyncTask is deferred. What you might have meant to write is:
LrTasks.startAsyncTask( ..., function()
LrTasks.execute( command )
-- waits for command to finish,
-- subject to limitations above
LrDialogs.whatever
end )
Hope this helps ...
Copy link to clipboard
Copied
thanks for your replay.
Is there a way to postpone opening any plugin UI until a task is complete?
Here are the steps for clarification:
1. Go to the Export panel
2. Click on plugin
3. Before any UI is shown I would like to run "LRTask.execute" wait for the return code
4. With return code then show UI appropiate for the user
5. Execute user options
Thanks
lmora
Copy link to clipboard
Copied
No, you can't stop the Export dialog from being shown. This would be a bad idea: If your plug-in failed or took an inordinately long time, then the other parts of the dialog (notably the part that let the user click away from your plug-in) would be unavailable.
What you should do instead is dim or hide the relevant parts of your plug-in's UI until you have the information you need. Look at the Flickr sample plug-in. It hides some functionality and dims the Export button until it's had a chance to confirm your identity through the Flickr API. This is the preferred model.