SDK Dialog Ok button only enabled if edit_field is not empty
What I want is to have the dialog Ok button only be enabled when a edit_field is not empty.
In the post https://community.adobe.com/t5/lightroom-classic-discussions/modale-validation/m-p/9351740 John Ellis gives the following example which I extended by one edit_field.
Setting the check on the popup_menu works, setting it on the popup_menu works not.
2 questions:
- What am I missing that this doesn't work for the edit_field
- What is the most easy way to disable the Ok button if an edit_field is empty.
If possible I want to stay away from using addObserver
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)
local res = LrDialogs.presentModalDialog {title = "Test",
contents = f:row {
bind_to_object = p,
f:popup_menu {value = bind ("selection"),
items = {{title = "A", value = "A"}, {title = "B", value = "B"}}
},
f:edit_field {
alignment = 'left',
place_horizontal = 0,
value = bind( 'taskDescription' ),
width_in_chars = 20,
},
},
-- actionBinding = {enabled = LrBinding.keyIsNotNil ("selection", p)}}
actionBinding = {enabled = LrBinding.keyIsNotNil "taskDescription", p)}}
end).
