Skip to main content
Inspiring
January 23, 2023
Answered

Change LrDialogs.presentModalDialog actionVerb text changed based on edit_field value

  • January 23, 2023
  • 1 reply
  • 230 views

By default my LrDialogs.presentModalDialog actionVerb is set to Done.

However, when a certain value is entered in the taskDescription edit_field, it should change to a different value.

 

Question: is it possible to change the actionVerb of a presentModalDialog to a different text based on the user input?

I tried the following with an addObserver and the static_field is changed correctly when the user enters "Change", however the button text remains the same.

 

local LrBinding = import "LrBinding"
local LrDialogs = import "LrDialogs"
local LrFunctionContext = import "LrFunctionContext"
local LrView = import "LrView"
local bind = LrView.bind

LrFunctionContext.callWithContext ("test", function (context)
		local f = LrView.osFactory ()
		local p = LrBinding.makePropertyTable (context)

		p.taskDescription = ""
		p.buttonTitle = "Ok"

		p:addObserver( 'taskDescription', function( p, key, newValue )
				if (newValue == "Change") then
					p.buttonTitle = "New name"
				end
			end )

		local res = LrDialogs.presentModalDialog {
			title = "Test",
			contents = f:row { 
				bind_to_object = p,

				f:edit_field {alignment = 'left', 
					place_horizontal = 0,
					width_in_chars = 20, immediate = true, 
					value = bind "taskDescription"
				},  
				f:static_text {alignment = 'left', 
					place_horizontal = 0,
					width_in_chars = 20,
					title = bind "buttonTitle"
				},  
				actionBinding = {
					enabled = LrBinding.keyIsNot ("taskDescription", "", p)
				},
				actionVerb = bind "buttonTitle"
			}
		}
	end)

 

This topic has been closed for replies.
Correct answer johnrellis

I don't see any way of changing the OK button label, other than what you've already tried.

1 reply

johnrellis
johnrellisCorrect answer
Legend
January 24, 2023

I don't see any way of changing the OK button label, other than what you've already tried.