MOHO.UpdateTable

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
MehdiZangenehBar
Posts: 54
Joined: Wed Feb 07, 2024 7:17 pm
Contact:

MOHO.UpdateTable

Post by MehdiZangenehBar »

Please someone explain what is MOHO.UpdateTable?
User avatar
hayasidist
Posts: 3569
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: MOHO.UpdateTable

Post 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.
User avatar
SimplSam
Posts: 1072
Joined: Thu Mar 13, 2014 5:09 pm
Location: London, UK
Contact:

Re: MOHO.UpdateTable

Post 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.
Moho 14.1 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB
Moho 14.1 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam


Sam
User avatar
MehdiZangenehBar
Posts: 54
Joined: Wed Feb 07, 2024 7:17 pm
Contact:

Re: MOHO.UpdateTable

Post by MehdiZangenehBar »

Well, I'm little bit confused about it, would you please show me a working useful example?
User avatar
KuzKuz
Posts: 506
Joined: Mon Aug 19, 2013 5:12 pm
Location: Ukraine

Re: MOHO.UpdateTable

Post by KuzKuz »

The simplest example is calling UpdateWidgets() for a non-modal dialog when changing the frame or layer.
User avatar
SimplSam
Posts: 1072
Joined: Thu Mar 13, 2014 5:09 pm
Location: London, UK
Contact:

Re: MOHO.UpdateTable

Post 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.

Image

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.
Moho 14.1 » Win 11 Pro 64GB » NVIDIA GTX 1080ti 11GB
Moho 14.1 » Mac mini 2012 8GB » macOS 10.15 Catalina
Tube: SimplSam


Sam
User avatar
MehdiZangenehBar
Posts: 54
Joined: Wed Feb 07, 2024 7:17 pm
Contact:

Re: MOHO.UpdateTable

Post by MehdiZangenehBar »

Great example! thanks!
User avatar
MehdiZangenehBar
Posts: 54
Joined: Wed Feb 07, 2024 7:17 pm
Contact:

Re: MOHO.UpdateTable

Post 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.
Post Reply