Copy link to clipboard
Copied
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)
I don't see any way of changing the OK button label, other than what you've already tried.
Copy link to clipboard
Copied
I don't see any way of changing the OK button label, other than what you've already tried.