我正在使用使用Lua的SDK寻找Adobe Lightroom的插件。我只是想了解他们的一个世界示例。
local LrFunctionContext = import 'LrFunctionContext'
local LrBinding = import 'LrBinding'
local LrDialogs = import 'LrDialogs'
local LrView = import 'LrView'
local LrColor = import 'LrColor'
local LrLogger = import 'LrLogger'
local myLogger = LrLogger( 'libraryLogger' )
MyHWLibraryItem = {}
myLogger:enable( "print" ) -- or "logfile"
function MyHWLibraryItem.outputToLog( message )
myLogger:trace( message )
end
function MyHWLibraryItem.showCustomDialog()
-- body of show-dialog function
LrFunctionContext.callWithContext( "showCustomDialog", function( context )
-- body of called function
local props = LrBinding.makePropertyTable( context ) -- create bound table
props.isChecked = true -- add a property key and initial value
-- create view hierarchy
local f = LrView.osFactory()
-- Create the contents for the dialog.
local c = f:row {
bind_to_object = props,
-- Add a checkbox and an edit_field.
f:checkbox {
title = "Enable",
value = LrView.bind( "isChecked" ),
},
f:edit_field {
value = "Some Text",
enabled = LrView.bind( "isChecked" )
}
}
local result = LrDialogs.presentModalDialog(
{
title = "Custom Dialog",
contents = c, -- the view hierarchy we defined
}
)
--this is where I am trying get the value of the text box
MyHWLibraryItem.outputToLog(c.row.checkbox.title)
end)
end
MyHWLibraryItem.showCustomDialog()
因此,我要做的是将edit_field对话框的值发送到控制台(即在Mac OSX中)。
问题: 1)如何访问对话框中的文本?
2)f:checkbox和f:edit_field怎么回事,其中没有()括号,而有{}括号?为什么这些函数不像f:edit_field()那样编写?