In my case that's exactly what I want, close ALL created float dialogs and reopen them on DoLayout. Please take a look at this example:
Code: Select all
ScriptName = 'Test_Script'
Test_Script = {}
Test_Script.first_float_dialog = nil
function Test_Script:OnMouseDown(moho, mouseEvent)
end
function Test_Script:DoLayout(moho, simple_dialog_layout)
if Test_Script.first_float_dialog ~= nil then
Test_Script.first_float_dialog.image_text_list:SetSelItem(true)
Test_Script.first_float_dialog = nil
end
for i = 1 , 5 do
local simple_dialog = LM.GUI.SimpleDialog(tostring(i), {})
local simple_dialog_layout = simple_dialog:GetLayout()
simple_dialog.image_text_list = LM.GUI.ImageTextList(100, 100, LM.GUI.MSG_OK)
simple_dialog_layout:AddChild(simple_dialog.image_text_list)
simple_dialog:DoModeless()
if Test_Script.first_float_dialog == nil then Test_Script.first_float_dialog = simple_dialog end
end
end
This code works perfect, but the crash will accure if we close one of the float dialogs by hitting the X button.
I will consider your advice and caution about the DoLayout, but really there is not ANY functionality to handle this? maybe try catch? or any other tip or trick to prevent the crash?