Tech Tip: View Pro Pause and Resume Rendering
PRODUCT: 4D | VERSION: 18 | PLATFORM: Mac & Win
Published On: June 14, 2021
Below is a utility method that can pause and resume the rendering of a 4D View Pro area. This can improve performance for looping code that is updating alot of cells.
// Method: VP_SuspendPaint C_TEXT($1) C_BOOLEAN($2) C_TEXT($vpArea_t) C_TEXT($jsScript_t) C_TEXT($res_t) C_OBJECT($res_o) If (Count parameters=2) $vpArea_t:=$1 $res_o:=WA Evaluate JavaScript(*;$vpArea_t;"Utils.spread;";Is object) If ($res_o=Null) $jsScript_t:="spread" Else $jsScript_t:="Utils.spread" End if If ($2=True) $jsScript_t:=$jsScript_t+".suspendPaint();" Else $jsScript_t:=$jsScript_t+".resumePaint();" End if $res_t:=WA Evaluate JavaScript(*;$vpArea_t;$jsScript_t;Is text) End if |
An example of using the method is:
VP_SuspendPaint("ViewProArea";True) // Some Long For Loop Updating Styles... VP_SuspendPaint("ViewProArea";False) |
This will pause the rendering, perform the loop, then resume the rendering which will redraw the entire 4D View Pro area once instead of the multiple times in each iteration of the loop.