<div dir="ltr">Hi,<br><br>I'm relatively new to JW Lua, but enjoying it very much. I'm trying to use the dialog window functionality so that a user can press a button and have some action take place. I registered a callback function, however, part of that function seems to be delayed until the user closes the (modal) dialog window. For example, the code below is intended to expand the currently selected region by one measure as soon as the user pushes the button. Unfortunately, that expansion doesn't happen until they push the button AND close the window.<br><br>```<div><div><br></div><div>local function newString(s)</div><div>    local str = finale.FCString()</div><div>    str.LuaString = s</div><div>    return(str)</div><div>end</div><div><br></div><div><br></div><div>local dialog = finale.FCCustomLuaWindow()</div><div>dialog:SetTitle(newString("Example utility"))</div><div><br></div><div><br></div><div>local button1 = dialog:CreateButton(0, 0)</div><div>button1:SetText(newString("Expand selection"))</div><div>button1:SetWidth(200)</div><div><br></div><div><br></div><div>local function expandSelection()</div><div>    -- this function expands the selection by one measure</div><div>    local region = finenv.Region()</div><div>    region:SetEndMeasure(region:GetEndMeasure() + 1)</div><div>    region:SetInDocument()</div><div>end</div><div><br></div><div>local function handle(control)</div><div>    expandSelection() -- why isn't this asynchronous, but the thing below is?</div><div>    finenv.UI():AlertInfo("This alert box happens right away, but the rest of the function doesn't.", "Alert")</div><div>end</div><div><br></div><div>dialog:RegisterHandleCommand(handle)</div><div> </div><div>dialog:ExecuteModal(nil)</div></div><div>```</div><div><br></div><div>What am I doing wrong here?</div><div><br></div><div>Thanks,</div><div><br></div><div>Jeff</div><div><br></div></div>