question

Matthew Gillespie avatar image
1 Like"
Matthew Gillespie asked Brandon Peterson edited

How to create only one instance of a GUI?

I've made a custom GUI for my object. When I double click the object a GUI opens, but if I keep clicking multiple GUIs are opening. How do I make sure that if one instance of GUI is open another instance is not created?

openlotsgui.fsm

FlexSim 17.1.2
gui
openlotsgui.fsm (18.8 KiB)
5 |100000

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

1 Answer

Matthew Gillespie avatar image
2 Likes"
Matthew Gillespie answered Brandon Peterson edited

I think you just need to add an OnPreOpen node to the GUI and call

standardpreopen(c);

in that node.

openoncegui.fsm


openoncegui.fsm (28.0 KiB)
· 1
5 |100000

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

Brandon Peterson avatar image Brandon Peterson ♦ commented ·

@Matthew Gillespie

Thanks for this! Working on the weekend and was super glad to find this post. I already had code in my OnPreOpen that was looking at other nodes in the GUI. It was throwing errors when I put the standardpreopen command at the start of the code. I could have put the command after that code but I wanted things to execute faster (my other code takes a bit of time). So, I put the following if statement around my code:

standardpreopen(c);
if(objectexists(c)){
     //more code
}


Thanks again,

Brandon

0 Likes 0 ·