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

SDK LrDialogs.presentModalDialog with table: how to add a new row

Participant ,
Feb 26, 2025 Feb 26, 2025

Copy link to clipboard

Copied

I managed to display a table with rows and column using the LrDialogs.presentModalDialog.

All the values from the orginal table I converted to a flat property table.

 

propertyTable = LrBinding.makePropertyTable(context)

 

 

Before adding the new row I display the table. This works fine
Ofcourse variable "c" contains all groups, rows and columns.

 

 

dialogValue = LrDialogs.presentModalDialog(
	{
		title = "My table",
		contents = c,
	}

 

 

Having my original table and a flattened projection of it as property table, below the table rows I added a button.

The button calls a function which performs the steps below:

  1. Adding a row to my original table
  2. Updating the property table with these new values
  3. Added a row to the contents in variable "c"
  4. After these steps I tried to stop and show the dialog again, however that doesn't work.

 

LrDialogs.stopModalWithResult(dialogValue)

dialogValue = LrDialogs.presentModalDialog(
	{
		title = LOC "$$$/LightroomStatistics/Dialogs/Translations=Translations",
		contents = c,
	}
)

 

Question

How can I redraw / redisplay  the modal form.

TOPICS
macOS , SDK , Windows

Views

140
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 , Feb 27, 2025 Feb 27, 2025

Here's an example of how to change the controls displayed dynamically (see the attached screen recording):

 

local LrDialogs = import "LrDialogs"
local LrView = import "LrView"
local f = LrView.osFactory ()

local nRows = 1
while true do 
    local rows = {spacing = f:control_spacing ()}
    for i = 1, nRows do 
        table.insert (rows, f:static_text {title = "Row " .. i})
        end

    table.insert (rows, f:push_button {title = "Add row", 
        action = function (button) 
            nRo
...

Votes

Translate
LEGEND ,
Feb 27, 2025 Feb 27, 2025

Copy link to clipboard

Copied

Here's an example of how to change the controls displayed dynamically (see the attached screen recording):

 

local LrDialogs = import "LrDialogs"
local LrView = import "LrView"
local f = LrView.osFactory ()

local nRows = 1
while true do 
    local rows = {spacing = f:control_spacing ()}
    for i = 1, nRows do 
        table.insert (rows, f:static_text {title = "Row " .. i})
        end

    table.insert (rows, f:push_button {title = "Add row", 
        action = function (button) 
            nRows = nRows + 1
            LrDialogs.stopModalWithResult (button, "refresh")
            end})

    local result = LrDialogs.presentModalDialog {title = "Test", 
        contents = f:column (rows)}
    if result ~= "refresh" then break end 
    end

 

Votes

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
Participant ,
Mar 01, 2025 Mar 01, 2025

Copy link to clipboard

Copied

This works great, you put me on track again.

 

Since I work with scrolled_view, I modified the code a little and now works also.
Simply replacing f:columns(rows) by f:scrolled_view(rows) didn't work.

while true do
	local outerRows = {}
	local rows = {}
	outerRows = { spacing = f:control_spacing() }
	for i = 1, nRows do
		table.insert(rows, f:static_text { title = "Row " .. i })
	end
	table.insert(outerRows, f:scrolled_view(rows))
	table.insert(outerRows, f:push_button { title = "Add row",
		action = function(button)
			nRows = nRows + 1
			LrDialogs.stopModalWithResult(button, "refresh")
		end })

	local result = LrDialogs.presentModalDialog { title = "Test",
		contents = f:column(outerRows) }
	if result ~= "refresh" then break end
end

 

Votes

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 03, 2025 Mar 03, 2025

Copy link to clipboard

Copied

I am writing a plugin for Lightroom in which the user can select multiple metadata fields to have "remapped" to different values upon export of an image. I'd like to give them a UI to specify which field will be updated, and how they would like to update it, but I do not know ahead of time how many metadata fields they would like to edit. Is there a way to use an "add row" button which, when clicked, will add a new row to the UI for them to specify these details for another metadata field?

 

I know about the LrBindings namespace and that it can be used to dynamically update properties of different UI elements (like the visibility property or the contents of a text field) but is it possible to create entirely new UI elements with a button as well?

Votes

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 03, 2025 Mar 03, 2025

Copy link to clipboard

Copied

Votes

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 03, 2025 Mar 03, 2025

Copy link to clipboard

Copied

LATEST

Votes

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