Hi Klaus,
KlausBusse wrote:
As soon as I click beside the dialog, it moves to the background
There is a callback for bringing to the front (see api doc), but also: make sure you pass save_frame=... in the args, so user can position outside Lr main window.
KlausBusse wrote:
Generally it would be much nicer if we could place LRViews in the Metadata pane, however to my understanding this is yet impossible, correct?
Correct.
|> "when the user is selecting another image"
You have to have an async task which constantly polls target photo - and make sure you stop the task when plugin is reloaded etc. otherwise multiple tasks will accumulate - it's tricky - you need a shutdown module, and a cleanup handler. shutdown detects plugin reload, and cleanup handler makes sure the task stops in case of error etc.
Shutdown module - LrShutdownPlugin in Info.lua (should have been called LrPluginReload, since it's only invoked when plugin is reloaded, NOT when Lr is shutdown, or when plugin is first loaded..). Often only needs to be one line - set a global boolean value to true, e.g. "_G.pluginReloaded=true".
Cleanup handler - see api doc for LrFunctionContext.
Task:
LrFunctionContext.postAsyncTaskWithContext( "Target photo change detector", function( context ) local killTask context:addCleanupHandler( function( s, m ) killTask = true end ) local lastTarget while not killTask and not pluginReloaded do local target = catalog:getTargetPhoto() if target ~= lastTarget then lastTarget = target local worked, didntWork = LrTasks.pcall( processChangedTarget, target ) -- process new target, but errors should not kill the task, since they can easily occur if user deletes target photo in mid-processing.. if didntWork then debugLog( didntWork ) -- debug.. end else LrTasks.sleep( .1 ) end end end )
*** Also, the task must stop when the floating dialog box is closed! (not shown).
*** Also, the task must stop when the floating dialog box is closed! (not shown).