question

Martin K5 avatar image
2 Likes"
Martin K5 asked Martin K5 commented

Is it possible to disable button in GUI

Hi,


I would like to ask if it is possible to disable button in GUI by code? I would like to have one button disabled by default and then activate it based on some action?


Thank you a lot,


Martin

FlexSim 22.2.0
codeguibuttondisable
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
3 Likes"
Jason Lightfoot answered Martin K5 commented

You should use:

treenode button= ........  //your button path
windowgray(windowfromnode(button),0);  // use 0 or 1 - reflecting the graystate.

This way the button is inactive and visibly disabled . This way it's clear to users that they should not try pressing the button and will not be left wondering if it worked or why it did not.

You could alternatively hide/show the button completely with:

windowshow(windowfromnode(button),0);  // 0 or 1 to reflect the hidden state

but that could leave a user puzzled as to why they don't find a button they were sure they'd seen on that gui.

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

Martin K5 avatar image Martin K5 commented ·
Yes, thank you a lot. This is what I was looking for.



0 Likes 0 ·
Felix Möhlmann avatar image
3 Likes"
Felix Möhlmann answered Felix Möhlmann commented

I would add a node to the buttons attribute tree and use its value as a condition in the OnPress code. Other parts of the GUI/model can then change the node's value and thus activate the buttons functionality.

capture1.png

buttonexample.gif

deactivate-button-fm.fsm


capture1.png (6.6 KiB)
buttonexample.gif (115.3 KiB)
· 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.

Joerg Vogel avatar image Joerg Vogel commented ·
@Felix Möhlmann is it possible to transfer a button object to an inactive gui?
0 Likes 0 ·
Felix Möhlmann avatar image Felix Möhlmann Joerg Vogel commented ·
Interesting question. I don't know to be honest.
0 Likes 0 ·

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.