I use SimpleDialog and DoModeless () to create the modeless dialog box, and then when I append or delete a button, I have to manually close script and reopen script .
Is there a function to reload SimpleDialog?Alternatively, there are other ways to reload the script itself?
Using XXX:Run(moho) causes multiple dialog boxes, and the old dialog box does not close.
How to reload the dialog or the script itself after using the SimpleDialog
Moderators: Víctor Paredes, Belgarath, slowtiger
How to reload the dialog or the script itself after using the SimpleDialog
I'm from China, currently using: Moho 15 » Win10 System












Re: How to reload the dialog or the script itself after using the SimpleDialog
There is currently no built-in function to dynamically update the structure of open dialogs - like adding or removing widgets, so a work-around would be to close and reopen the dialog. However - there is currently no built-in mechanism to close dialogs, so ...
Something derived from @Rai Lopez
Add a textlist which sends Cancel when an item is selected.
Then in your HandleMessage code, you will trigger the cancelTextList by selecting an item to close the dialog, then open a new one.
Also ensure that you are using moho 14.1 (latest) as it is a lot more stable with modeless dialogs that 14.0
Something derived from @Rai Lopez
Add a textlist which sends Cancel when an item is selected.
Code: Select all
d.cancelTextList = LM.GUI.ImageTextList(0, 1, LM.GUI.MSG_CANCEL)
d.cancelTextList:AddItem("", false)
l:AddChild(d.cancelTextList, LM.GUI.ALIGN_LEFT, 0)
Code: Select all
self.cancelTextList:SetSelItem(self.cancelTextList:GetItem(0), false) -- Close
myScript.myDlog = myScriptDialog:new(moho) -- ReCreate
myScript.myDlog:DoModeless() -- ReOpen
Moho 14.3 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB
Moho 14.3 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam
Sam
Moho 14.3 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam
Sam
Re: How to reload the dialog or the script itself after using the SimpleDialog
Thank you SimplSam, I have referenced Lukas' LK_LayerFinder script, combined with the code you provided, successfully added new buttons to the control dynamically, but the window coordinates after reloading the script are always in the middle of the screen. I hope the official can add the API for saving the location coordinates of the modeless dialog box, as well as other APIs such as delayed execution.SimplSam wrote: ↑Wed Nov 08, 2023 6:10 pmCode: Select all
d.close = LM.GUI.ImageTextList(0, 1, LM.GUI.MSG_CANCEL) l:AddChild(d.close, LM.GUI.ALIGN_LEFT, 0)
Code: Select all
self.close:SetSelItem(false) -- Close myScript.dlog = nil myScript.dlog = myScript:new(moho) -- ReCreate myScript.dlog:DoModeless() -- ReOpen
I'm from China, currently using: Moho 15 » Win10 System











