<div dir="ltr"><div>I am interested in comments on a proposed implementation of modeless dialogs for lua scripts. A modeless dialog means that the plugin for Finale-embedded Lua (RGP Lua in this case) has to exit back to Finale leaving the Lua state intact and runnable. This implies the following requirements.</div><div><br></div><div>1. The script has to manage its own Undo blocks.</div><div>2. The script has to be able to notify the RGP Lua plugin when it terminates.</div><div>3. All useful processing has to be done by callbacks to lua functions in the script.</div><div><br></div><div>To this end I am proposing the following enhancements to the RGP Lua scripting environment.</div><div><br></div><div>1. Add <span style="font-family:monospace">finaleplugin.HandlesUndo = true</span> to notify RGP Lua that a script will manage its own undo block(s).</div><div>2. Add <span style="font-family:monospace">finenv.RegisterModelessDialog(customluawindow)</span> to allow a script to register one (and only one) FCCustomLuaWindow instance with RGP Lua as a modeless dialog window. When this window closes, RGP Lua terminates the Lua state for the script.</div><div>3. Add <span style="font-family:monospace">finenv.EndUndoBlock(success)</span> to allow a script to end the current undo block without starting another.<br></div><div>4. Add <span style="font-family:monospace">ShowModeless()</span> method to FCCustomLuaWindow. If you have registered the instance, it opens the window modelessly and returns <span style="font-family:monospace">true</span>. If you have not registered it, the method returns <span style="font-family:monospace">false</span> and does nothing.</div><div><br></div><div>Here is a brief Hello World example. This example is currently working in my dev environment. I am polling this list to find out if anyone can think of anything else that we need.</div><div><br></div><div><span style="font-family:monospace">function plugindef()<br>    finaleplugin.IsModeless = true<br>end</span></div><div><span style="font-family:monospace"><br>-- scratch FCString<br>local str = finale.FCString()<br>-- create a new dialog<br>local dialog = finale.FCCustomLuaWindow()<br>-- add a button to say "Hello World"<br>local helloWorldButton = dialog:CreateButton(0, 0)<br>str.LuaString = "Hello World"<br>helloWorldButton:SetWidth(100)<br>helloWorldButton:SetText(str)<br>dialog:RegisterHandleControlEvent (<br>    helloWorldButton,<br>    function(control)<br>        -- if this modifies the Finale document, call finenv.StartNewUndoBlock("My Undo Text")<br>        finenv.UI():AlertInfo("Hello World", "")<br>        -- if updates were successful, call finenv.EndUndoBlock(true)<br>        -- if updates were not successful, call finenv.EndUndoBlock(false)<br>    end<br>)<br>dialog:CreateOkButton()<br>finenv.RegisterModelessDialog(dialog) -- must register, or ShowModeless does nothing<br>dialog:ShowModeless()</span></div><div><br></div><div><br></div></div>