Skip to main content
Participating Frequently
October 22, 2018
Question

close presentFloatingDialog

  • October 22, 2018
  • 3 replies
  • 858 views
LrDialogs.presentFloatingDialog(_PLUGIN, {

  title = '享像派',

  contents = content,

  blockTask = true,

  onShow = function()

  

   end,

  windowWillClose = function()

  

   end

  }) 

How to close presentFloatingDialog with onShow function

This topic has been closed for replies.

3 replies

johnrellis
Genius
October 23, 2018

Here's what the API documentation says:

  • onShow: (Function, optional) If supplied, a function which will be called when the dialog first shows up on the screen. It will be passed a single argument; a table containing two entries, which are both functions that can be invoked to manipulate the dialog. The 'toFront' entry is the function to call to ensure that the dialog is the frontmost window immediately after the call. The 'close' entry is the function to call to programmatically close the dialog window.

So the definition of the "onShow" function would have this structure:

LrDialogs.presetFloatingDialog (_PLUGIN, {...

    onShow = function (t)

        ...save t in a persistent object or global variable...

          end

    ...})

When the code wants to close the dialog, it calls t.close().

27shutterclicks
Inspiring
September 17, 2022

I am trying to figure out the onShow function also. Can you please elaborate on how to "save t in a persistent object or global variable"?

 

I tried :

 

onShow = function(t)
     tofront = t
end

 

and:

 

onShow = function(t)

   tofront = t["toFront"]

end

 

But none of these seem to be doing anything. 

27shutterclicks
Inspiring
September 20, 2022

I figured it out once I got a better grasp of Lua global variables. Here is the fix, in case anyone else may be wondering.

 

First, create a global variable with a name of your choosing. In my case it was "floatingDialog". This can be placed anywhere before invoking the dialog.

_G["floatingDialog"] = {}

 

Then, when calling the floating dialog, save the parameter of the onShow function to that global variable:

LrDialogs.presentFloatingDialog(_PLUGIN,
    {
        title = "My Dialog Title",
        contents = contents,
        onShow = function(toFront)
            _G["floatingDialog"] = toFront
        end
    }
)

 

Just Shoot Me
Legend
October 23, 2018
johnrellis
Genius
October 22, 2018

Please repost this in the SDK forum and I'll answer there: Lightroom SDK .  That will ensure that other developers will see the question and answer.