Discussion Closed This discussion was created more than 6 months ago and has been closed. To start a new discussion with a link back to this one, click here.
How to create a "toggle" in application builder
Posted 10 févr. 2016, 11:00 UTC−5 Simulation Apps, Results & Visualization Version 5.1 4 Replies
Please login with a confirmed email address before reporting spam
Hi there,
I am building an application and I would like to include a control to toggle the state of filters in plots. I have created the methods using code similar to the following:
model.result("pg5").feature("surf1").feature("filt1").active(true);
model.result("pg3").feature("arws1").feature("filt1").active(true);
model.result("pg3").feature("surf1").feature("filt1").active(true);
and
model.result("pg5").feature("surf1").feature("filt1").active(false);
model.result("pg3").feature("arws1").feature("filt1").active(false);
model.result("pg3").feature("surf1").feature("filt1").active(false);
I can assign buttons to each of these methods and it does work as expected, but this is not a nice UI for the end user. I would much rather have a radio button or some other control that toggled between the filters being enabled and disabled. Even better would be if the button image changed depending on the current state of the filters.
I am pretty sure it would involve an "if" statement to determine the current state of the filters and then depending on the state, the button that reflects the "other" option would be made visible. i.e. if the filters were currently disabled, a button would show to enable the filters and the button to disable the filters would be hidden. (I am thinking these 2 buttons could sit directly on top of eachother in the UI, is this feasible)?
I am thinking this would be an easy thing for someone familiar with coding... sadly, I am not an experienced coder so would welcome any pointers! I can think of several situations where a toggle for a certain setting would be useful, so hopefully the feedback will help in other sutuations too.
Thanks in advance for any feedback, I can post my model if it would help.
Mark
I am building an application and I would like to include a control to toggle the state of filters in plots. I have created the methods using code similar to the following:
model.result("pg5").feature("surf1").feature("filt1").active(true);
model.result("pg3").feature("arws1").feature("filt1").active(true);
model.result("pg3").feature("surf1").feature("filt1").active(true);
and
model.result("pg5").feature("surf1").feature("filt1").active(false);
model.result("pg3").feature("arws1").feature("filt1").active(false);
model.result("pg3").feature("surf1").feature("filt1").active(false);
I can assign buttons to each of these methods and it does work as expected, but this is not a nice UI for the end user. I would much rather have a radio button or some other control that toggled between the filters being enabled and disabled. Even better would be if the button image changed depending on the current state of the filters.
I am pretty sure it would involve an "if" statement to determine the current state of the filters and then depending on the state, the button that reflects the "other" option would be made visible. i.e. if the filters were currently disabled, a button would show to enable the filters and the button to disable the filters would be hidden. (I am thinking these 2 buttons could sit directly on top of eachother in the UI, is this feasible)?
I am thinking this would be an easy thing for someone familiar with coding... sadly, I am not an experienced coder so would welcome any pointers! I can think of several situations where a toggle for a certain setting would be useful, so hopefully the feedback will help in other sutuations too.
Thanks in advance for any feedback, I can post my model if it would help.
Mark
4 Replies Last Post 11 févr. 2016, 03:57 UTC−5