Copy link to clipboard
Copied
Is there a way to add an observer or something in order to know when the user has selected a different photo from within the library module? Essentially I want a function to be called when the user changes the selected photo within the library.
You could try the undocumented LrApplication.addActivePhotoChangeObserver. Its signature may be similar to LrDevelopController.addAdjustmentChangeObserver. Make sure you're trapping all errors or using a debugger while you're experimenting with it.
I vaguely recall trying it out a couple years ago and deciding not to use it, but I can't remember why. I have an even vaguer memory that Rob Cole may have noticed that some changes in selection weren't getting reported.
A couple of my plugins poll ev
...Copy link to clipboard
Copied
You could try the undocumented LrApplication.addActivePhotoChangeObserver. Its signature may be similar to LrDevelopController.addAdjustmentChangeObserver. Make sure you're trapping all errors or using a debugger while you're experimenting with it.
I vaguely recall trying it out a couple years ago and deciding not to use it, but I can't remember why. I have an even vaguer memory that Rob Cole may have noticed that some changes in selection weren't getting reported.
A couple of my plugins poll every quarter of a second or so for changes to module and selection. It offends the more delicate architectural sensibilities, but it works well without imposing a noticeable CPU cost.
Copy link to clipboard
Copied
I implemented the LrApplication.addActivePhotoChangeObserver function. So far I have not noticed any adverse side effects, it's working for me as expected. I'll keep an eye out for anything weird as its undocumented. Thanks!
Copy link to clipboard
Copied
Hi... I'm trying implement this method. But i cant. Can you see me how you do this?
Copy link to clipboard
Copied
Maybe Avizzv92​ can provide more detail, but here's an outline of what I recall from my experiment several years ago:
LrFunctionContext.callWithContext ("", function (context)
...
LrApplication.addActivePhotoChangeObserver (context, nil,
function ()
...called when the active photo changes...
end)
...
LrDialogs.presentFloatingDialog (plugin, {...blockTask = true...})
end)
Note that you attach observer functions to LrFunctionContext objects, and that when callWithContext() returns, the context is destroyed and the observer functions cease being called. So after calling addActivePhotoChangeObserver(), the task needs to block, either by calling presetFloatingDialog() or with a spin loop that calls sleep().