Page 1 of 1
MOHO.UpdateTable
Posted: Tue May 07, 2024 10:38 am
by MehdiZangenehBar
Please someone explain what is MOHO.UpdateTable?
Re: MOHO.UpdateTable
Posted: Tue May 07, 2024 12:08 pm
by hayasidist
https://mohoscripting.com/lm_utilities catalogues the functions in LM_Utilities. One function is MOHO.RunUpdateTable(moho). This function takes the table MOHO.UpdateTable and calls each function that is held in the table. For all practical purposes, it should be regarded as internal to Moho. Specifically, there is no way to provide any parameters to the called functions.
Re: MOHO.UpdateTable
Posted: Tue May 07, 2024 4:07 pm
by SimplSam
I would say prior to Moho 14 it was pretty useless. But now that we have access to ScriptInterfaceHelper/MohoObject() - you can access practically anything.
So if you are running Modeless Dialogs, then you can effectively set up a callback to refresh the dialogs etc automatically on Frame, Layer, Document, Selected Items change etc etc.
One thing to note: It gets called a lot. So you have to do a bit of defensive programming to stop it wasting CPU for no reason.
Re: MOHO.UpdateTable
Posted: Wed May 08, 2024 2:04 am
by MehdiZangenehBar
Well, I'm little bit confused about it, would you please show me a working useful example?
Re: MOHO.UpdateTable
Posted: Wed May 08, 2024 9:54 am
by KuzKuz
The simplest example is calling UpdateWidgets() for a non-modal dialog when changing the frame or layer.
Re: MOHO.UpdateTable
Posted: Wed May 08, 2024 12:41 pm
by SimplSam
A practical example is presented below in the SS Point Info Panel, which presents information on selected points and updates the dialog when that selection/info changes. It has some built-in updates defense - as it is set ignore frequent update calls - and calls other than for Doc,Layer, Point Selection changes.
https://drive.google.com/file/d/19sTvzb ... sp=sharing
In an ideal world - you would be able to register in the Update Table for specific events - rather than being called for practically everything that changes.
Re: MOHO.UpdateTable
Posted: Wed May 08, 2024 11:22 pm
by MehdiZangenehBar
Great example! thanks!
Re: MOHO.UpdateTable
Posted: Wed May 08, 2024 11:24 pm
by MehdiZangenehBar
KuzKuz wrote: ↑Wed May 08, 2024 9:54 am
The simplest example is calling UpdateWidgets() for a non-modal dialog when changing the frame or layer.
So UpdateWidgets not happening for non-modal by default? never notice that.