• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

Observe when a photo has been selected within the library module?

Explorer ,
Aug 06, 2017 Aug 06, 2017

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.

TOPICS
SDK

Views

787

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Aug 15, 2017 Aug 15, 2017

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

...

Votes

Translate

Translate
LEGEND ,
Aug 15, 2017 Aug 15, 2017

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 19, 2017 Aug 19, 2017

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 25, 2019 Mar 25, 2019

Copy link to clipboard

Copied

Hi... I'm trying implement this method. But i cant. Can you see me how you do this?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 25, 2019 Mar 25, 2019

Copy link to clipboard

Copied

LATEST

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().

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines