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

Feature Request: Ability to Not Have an Action Button in Dialog Box

LEGEND ,
Jun 26, 2010 Jun 26, 2010

As it stands, the dialog box requires you to have an "OK" button, and a "Cancel" button (names can be changed...) - both of which will dismiss the dialog box. More buttons than that and you have to define an accessory view or put buttons in the views - all of which is fine, except when a dialog box is used more like an application frame, in which case it would be preferrable if only one button dismissed the dialog box (e.g. 'Done').

Rob

TOPICS
SDK
2.9K
Translate
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 , Jun 26, 2010 Jun 26, 2010

Here's an undocumented way to create a dialog with just a single "Done" button.  Not sure you want to rely on this though :-;

local LrDialogs = import 'LrDialogs'
local LrFunctionContext = import 'LrFunctionContext'
local LrTasks = import 'LrTasks'
local LrView = import 'LrView'

local function findButton (x, label, visited)
    if visited == nil then visited = {} end

    if type (x) ~= "table" or visited then return nil end
    visited = true
   
    if x._WinClassName == "AgViewWinPushButton" and

    

...
Translate
LEGEND ,
Jun 26, 2010 Jun 26, 2010

Here's an undocumented way to create a dialog with just a single "Done" button.  Not sure you want to rely on this though :-;

local LrDialogs = import 'LrDialogs'
local LrFunctionContext = import 'LrFunctionContext'
local LrTasks = import 'LrTasks'
local LrView = import 'LrView'

local function findButton (x, label, visited)
    if visited == nil then visited = {} end

    if type (x) ~= "table" or visited then return nil end
    visited = true
   
    if x._WinClassName == "AgViewWinPushButton" and

       x.title == label then
        return x;
        end
       
    for k, v in pairs (x) do
        local result = findButton (v, label, visited)
        if result then return result end
        end
   
    return nil
    end
   
local f = LrView.osFactory()

local controls = f:column {
    f:static_text {title = "Look Ma! No OK or Cancel!"},
    f:edit_field {value = "fields"},
    f:push_button {title = "Do It"}}

LrTasks.startAsyncTask (function ()
    while true do
        local okButton = findButton (controls, "OK")
        if okButton then
            okButton.enabled = false
            okButton.visible = false
            return
            end
        LrTasks.sleep (0.1)
        end
    end)

LrDialogs.presentModalDialog {
    title = "Test", contents = controls, cancelVerb = "Done"}

Translate
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 ,
Jun 26, 2010 Jun 26, 2010

John - You are so "the man"!

PS - To the Adobe SDK workers - I still would like direct support in the SDK/API. The present work-around gets me through the day, but its klugy and leaves a dead-zone next to the "Cancel" button where the invisible "OK" button is hiding.

Thanks,

Rob

Translate
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
Guest
Aug 08, 2011 Aug 08, 2011

Seconded.

Translate
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 ,
Aug 08, 2011 Aug 08, 2011

Yeah, I've been using a slightly enhanced version of John Ellis solution for a while, but it just stopped working on the Mac (some Macs?). I guess something changed under the hood - needs to be re-engineered.

Official documented support would be better indeed.

PS - Another gotcha of the above approach: edited text values are not commited before exiting when 'Cancel' button is used as 'OK' button. (on Windows that is, they are not commited anyway on Mac, even if 'OK' button is used, so you have to set immediate to true if you want them commited on both platforms.).

Translate
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
Community Beginner ,
Oct 18, 2013 Oct 18, 2013

On the Mac you can catch the button via "_NSClass". Modify John's code as follows and it works on both plattforms:

    if WIN_ENV then

        if x._WinClassName == "AgViewWinPushButton" and x.title == label then

            return x

        end

    elseif MAC_ENV then

        if x._NSClass == "NSButton" and x.title == label then

            return x

        end

    else

        return nil

    end

HTH someone

cb

Translate
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 ,
Oct 18, 2013 Oct 18, 2013

johnbeardy's solution described above has been documented in both the LR 4 and 5 SDKs.  Does it not work for you?

Translate
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
Community Beginner ,
Oct 18, 2013 Oct 18, 2013

I have not seen that. Where is it documented?

Translate
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 ,
Oct 18, 2013 Oct 18, 2013

In the LR 4/5 SDK documentation under LrDialogs.presentModalDialog.

Translate
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
Community Beginner ,
Oct 18, 2013 Oct 18, 2013

I want to enable/disable the default button depending on the users input instead of hiding a button.

Translate
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 ,
Oct 18, 2013 Oct 18, 2013

I want to enable/disable the default button depending on the users input instead of hiding a button.

I don't think you'll be able to do that with the documented method of "< exclude >".

Translate
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
Community Beginner ,
Oct 18, 2013 Oct 18, 2013
LATEST

John R. Ellis schrieb:

I want to enable/disable the default button depending on the users input instead of hiding a button.

I don't think you'll be able to do that with the documented method of "< exclude >".

You're right and my mistake: I mean not Johns code, I mean Rob Coles code in the first answer (findButton function).

Translate
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
Community Expert ,
Aug 11, 2011 Aug 11, 2011

Rob

Try this currently undocumented / unsupported value:

                cancelVerb = "< exclude >",   -- Must be exact including the spaces

I only learnt about it recently but apparently it's been lurking there since LR1 and may get documented in LR4.

John

Translate
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