[JW Lua] Button press callback

Jari Williamsson jari.williamsson at mailbox.swipnet.se
Wed Nov 18 00:16:39 CET 2015


Charles,

Below is sample code for both your questions (setting up a tree control 
and responding to button command in a dialog).

The control IDs are set up automatically by the "Create" methods. Get 
the object from the "Create" method to manipulate the object.


Best regards,

Jari Williamsson

-----

-- Create the dialog and its controls
local str = finale.FCString()
local dialog = finale.FCCustomLuaWindow()
local mybutton = dialog:CreateButton(0, 0)
str.LuaString = "My Button"
mybutton:SetText(str)
local mytree = dialog:CreateTree(0, 30)
dialog:CreateOkButton()
dialog:CreateCancelButton()

-- Initialize the tree
str.LuaString = "Parent Tree Node"
local parentnode = mytree:AddNode(nil, true, str)
str.LuaString = "Child Item 1"
mytree:AddNode(parentnode, false, str)
str.LuaString = "Child Item 2"
mytree:AddNode(parentnode, false, str)

-- The command callback
local function mycommandhandler(thecontrol)
     if thecontrol:GetControlID() == mybutton:GetControlID() then
         finenv.UI():AlertInfo("The button 'mybutton' was pressed", 
"Button Pressed")
     end
end

-- Register the callback
dialog:RegisterHandleCommand(mycommandhandler)
if (dialog:ExecuteModal(nil) == 1) then
     -- Ok button was pressed
end

-----


On 2015-11-17 21:02, Charles O. Lawrence wrote:
> Jari and JW Lua fans,
>
> I am trying to set up a FCCustomLuaWindow so that when I press a given
> button whose control ID I know, it calls a particular function to do
> something.  I am struggling with the RegisterHandleCommand and how to
> pass the control ID, if that is what you do.  A brief explanation of the
> procedure and/or a code sample would be greatly appreciated.
>
> Thanks,
>
> Charles
>
>
>
> _______________________________________________
> JWLua mailing list
> JWLua at jwmusic.nu
> http://jwmusic.nu/mailman/listinfo/jwlua_jwmusic.nu
>






More information about the JWLua mailing list