question

Martin K5 avatar image
0 Likes"
Martin K5 asked Jason Lightfoot commented

How to refresh GUI window?

Hi,

I have a model with custom GUI, where I have a reference to GlobalTable. Through this GUI I am able to change GlobalTable's cell color based on value change. This is done without a problem, the cell's color changes, but the visual part is not affected. Even if I press the F5 to refresh the GUI. What I have to do is to save the model and then press the F5 button and the color changes.


Is there any command to do this as it is for combobox (refreshcombobox)?


Thank you,


Martin

FlexSim 23.1.0
color changecustom guiusing codecombobox
· 2
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Jason Lightfoot avatar image Jason Lightfoot ♦ commented ·
Have you tried repaintview() and refreshview() ?
0 Likes 0 ·
Martin K5 avatar image Martin K5 Jason Lightfoot ♦ commented ·

Yes, I have tried that, but without improvement.

The desired goal:

  • - to open model and see the GUI (one cell should be colored)
  • - then to change the cell's color and based on some action (command) refresh the view and see the changed color in the cell
  • 1691410929277.png


I am also attaching the model if you would be able to help me more?


Thank you,


Martin


ColorGT_demo.fsm

0 Likes 0 ·
1691410929277.png (46.3 KiB)
colorgt-demo.fsm (26.2 KiB)

1 Answer

·
Jonah K avatar image
3 Likes"
Jonah K answered Jason Lightfoot commented

The main problem is that you are changing the FlexScript code then are not building it. When you change a treenode that has FlexScript data, you must then Build the Node FlexScript or Build All FlexScript in order for your changes to be complied. (This is done when you hit Save) You can add a Build FlexScript button to your toolbar in Global Preferences > Customize Toolbar, or you can right click on a treenode and select Build > Build Node FlexScript. But I'd recommend that you use the buildnodeflexscript() command. I ran this script which uses that command and I referenced the Col2Units node in the GUI, and the cell changed to the correct color in "bgColor" whenever I ran the script.

buildnodeflexscript(Model.find("MODEL:/Tools/GUIs/test/table2>style/FS_CELL_FORMATTING/Col2Units"));
Object gui = Model.find("MODEL:/Tools/GUIs/test");
refreshview(gui);


· 4
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Martin K5 avatar image Martin K5 commented ·

Thank you for your detailed answer. I did not know about this and it works. It solved the problem when you change manually/by code the treenode's FlexScritp and you want to see the desired change in the GUI. But what if I have dashboard with GUI class and change the treenode? As I do so, the GUI class in dashboard does not show the change only the freshly opened GUI (done by your code).


I am also attaching the model, would you be so kind to help?


Thank you,

Martin

ColorGT_demo.fsm

0 Likes 0 ·
colorgt-demo.fsm (26.7 KiB)
Jonah K avatar image Jonah K ♦ Martin K5 commented ·

For a dashboard table GUI, you need to refresh the dashboard widget. So in all, you'll need to build the Node FlexScript of the treenode you changed, get the Dashboard widget with getdashboardcontrol("your_gui_ID"), call the Refresh function on the ownerobject of the widget, then refresh the view.

buildnodeflexscript(Model.find("MODEL:/Tools/GUIs/test/table2>style/FS_CELL_FORMATTING/Col2Units"));
Object dash = getdashboardcontrol("gui_class"); 
function_s(ownerobject(dash), "refresh");
refreshview(dash);

I had to close your dashboard and open it again to get the Properties panel to focus on the widget so you can see the gui ID.

colorgt-demo_JK.fsm

1 Like 1 ·
colorgt-demo-jk.fsm (26.8 KiB)
Martin K5 avatar image Martin K5 Jonah K ♦ commented ·
Hi,


sorry for late response. I ran your model and that is exactly what I was looking for. Still I have one question: Is is possible to deselect the GUI in dashboard after running the refresh command (the provided code)?


Thank you,


Martin

0 Likes 0 ·
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.