Skip to main content
Inspiring
February 25, 2024
Answered

Break code of dialogbox into smaller parts

  • February 25, 2024
  • 1 reply
  • 99 views

I have a quite a large dialogbox, and for code maintaining or adding future options. I would like to break this up in several code pieces.

 

LrFunctionContext.callWithContext ("Main", function (context)
		local f = LrView.osFactory ()
		local properties = LrBinding.makePropertyTable (context)
		-------- Default values for boxes --------
		properties.SourceDir 			= ""
		properties.NewFileName 			= ""
		properties.KeepOriginalFile 	= "noKeepOriginalFile"
		properties.MergeExif 			= "yesMergeExif"
		properties.NewFileExtention 	= "tif"
		properties.CreateExifToolDir 	= "yesCreateExifToolDir"
		properties.SaveNotes 			= "noSaveNotes"
		--------- Get the default browse folder--------
		defaultFolder 					= AFConfigFunctions.readConfig("export")
		
		--------- Show the dialog window --------
	local result = LrDialogs.presentModalDialog {
			title = "Metadata import",
			contents = f:column {
				spacing 		= f:label_spacing(),
				fill_horizontal = 1,
				font 			= "<system>",
				bind_to_object 	= properties,
				
				AFMetadataInsertDialog.ShowLogo(f)

But I always get errors.

function AFMetadataInsertDialog.ShowLogo(f)
	return 
		
			{
			-------- Logo --------
			f:row {
				alignment 	= "right",
				margin_left = "870",
				f:picture {
					value 	= _PLUGIN:resourceId("/img/Logo.png"),
				}
			},
			f:spacer{
				width 	= "100%",
				height 	= "5",
			},	
		}
			
end	

Is this possible and how ?

Patrick

 

 

This topic has been closed for replies.
Correct answer johnrellis

AFMetadataInsertDialog.ShowLogo(f) must return a single view object, but it is instead returning an array of view objects that gets inserted into the containing column as a single element. Each element of a column must be a view object, not an array of view objects. 

 

Wrap the result of ShowLogo() in a column:

 

function AFMetadataInsertDialog.ShowLogo(f)
    return f:column {
        ...}

 

1 reply

johnrellis
johnrellisCorrect answer
Legend
February 25, 2024

AFMetadataInsertDialog.ShowLogo(f) must return a single view object, but it is instead returning an array of view objects that gets inserted into the containing column as a single element. Each element of a column must be a view object, not an array of view objects. 

 

Wrap the result of ShowLogo() in a column:

 

function AFMetadataInsertDialog.ShowLogo(f)
    return f:column {
        ...}