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

Change LrDialogs.presentModalDialog actionVerb text changed based on edit_field value

Explorer ,
Jan 23, 2023 Jan 23, 2023

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)

 

TOPICS
macOS , SDK , Windows

Views

61

Likes

Translate

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 , Jan 23, 2023 Jan 23, 2023

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

Likes

Translate

Translate
LEGEND ,
Jan 23, 2023 Jan 23, 2023

Copy link to clipboard

Copied

LATEST

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

Likes

Translate

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