C
5: Creating a User Interface for Your Plug-in
HAPTER
}
)
if result == 'ok' then -- action button was clicked
LrHttp.openUrlInBrowser( properties.url )
end
end )
Making labels line up
Typically, a dialog contains vertical sets of controls and their labels. The following code demonstrates how
make right-aligned labels on the left side of the dialog, with matching left-aligned controls on the right
side.
To make this happen, the example uses the
The
alignment
at least one of these labels is wider than the text it is showing, the labels need to be right-aligned.
Labels should generally be right-aligned in any case, because if the dialog is translated, the size of the
text changes.
The namespace function
its own, but indicates that this property value is to be shared across the hierarchy with other
properties that share the same identifier. In this case, the
use the same identifier,
used as the width for both of them.
local LrDialogs = import "LrDialogs"
local LrFunctionContext = import "LrFunctionContext"
local LrView = import "LrView"
LrFunctionContext.callWithContext( 'bindingExample', function( context )
local f = LrView.osFactory() -- obtain view factory
local contents = f:column { -- define view hierarchy
spacing = f:control_spacing(),
f:row {
},
f:row {
actionVerb = "Go",
property determines whether a control is right-aligned, left-aligned, or centered. Since
LrView.share()
label_width
spacing = f:label_spacing(),
f:static_text {
title = "Name:",
alignment = "right",
width = LrView.share "label_width", -- the shared binding
},
f:edit_field {
width_in_chars = 20,
},
-- label for the action button
property and the
alignment
binds a property value to an identifier that has no value of
. When layout occurs, the largest
Determining layout 111
LrView.share()
of both labels is shared because they
width
value of the two labels is
width
function.