[JW Lua] Dialog callbacks only partially asynch?

Jeff Cox jeff.jtcox at gmail.com
Fri Oct 13 00:36:56 CEST 2017


Hi,

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.

```

local function newString(s)
    local str = finale.FCString()
    str.LuaString = s
    return(str)
end


local dialog = finale.FCCustomLuaWindow()
dialog:SetTitle(newString("Example utility"))


local button1 = dialog:CreateButton(0, 0)
button1:SetText(newString("Expand selection"))
button1:SetWidth(200)


local function expandSelection()
    -- this function expands the selection by one measure
    local region = finenv.Region()
    region:SetEndMeasure(region:GetEndMeasure() + 1)
    region:SetInDocument()
end

local function handle(control)
    expandSelection() -- why isn't this asynchronous, but the thing below
is?
    finenv.UI():AlertInfo("This alert box happens right away, but the rest
of the function doesn't.", "Alert")
end

dialog:RegisterHandleCommand(handle)

dialog:ExecuteModal(nil)
```

What am I doing wrong here?

Thanks,

Jeff
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://jwmusic.nu/pipermail/jwlua_jwmusic.nu/attachments/20171012/685dc510/attachment.html>


More information about the JWLua mailing list