chrisan
Senior Member
Senior Member
Posts: 108
Joined: Sun Feb 16, 2014 3:54 pm
Contact: Send private message

Change Button State Using State Variable

Fri Jan 20, 2017 6:22 pm

OK - so how do I make a button for a light look different when it is in either its on or off state?

I tried to do it as pictured in the attachment. But the button just disappears when I launch the app. I kind of know where the button is, though, and when I click in that area the light toggles. I tried to use the Homemodes example in myServer to create the myServer command for my state variables. Not sure if I got the syntax exactly right. I did try to export the Homemodes examples to text but myServer flashed a message saying the text file had been stored in a directory called C:\Program Files (x86)\Allonis\myServer\Data. I don't have a subfolder named Data on my myServer install. So I created one and re-exported but nothing was in the directory.

Thoughts? Thanks, Chris
Attachments
States.jpg
States.jpg (511.25 KiB) Viewed 569 times

chrisan
Senior Member
Senior Member
Posts: 108
Joined: Sun Feb 16, 2014 3:54 pm
Contact: Send private message

Re: Change Button State Using State Variable

Fri Jan 20, 2017 6:43 pm

I guess my follow up question would be how do I change the state of other buttons based on a state change of a clicked button.
I have some 6 button UPB switches where I can set this behavior for mutually exclusive scenes.

Say I have some buttons in a myDesigner scene that look like this:

Living Scene 1
Living Scene 2
Living Scene 3
Living Scene 4

Living Scene 2 is the active scene

Now I click on Living Scene 4 - the buttons then need to look like this

Living Scene 1
Living Scene 2
Living Scene 3
Living Scene 4

The state of the Living Scene 2 button has changed based on the click (or screen touch) of the Living Scene 4 button. How to accomplish??

Also, when I click on the real Living Scene 4 button on an actual UPB membrane switch, how do I get the corresponding buttons on the myDesigner scene to stay in synch?

If someone could help me figure this out it would probably keep me busy for a while. Probably write a little tutorial afterwards. :D :D

Thanks, Chris

User avatar
AllonisDave
Founder
Founder
Posts: 11454
Joined: Fri Feb 07, 2003 8:56 am
Location: Newport Beach, CA
Contact: Send private message

Re: Change Button State Using State Variable

Sat Jan 21, 2017 11:48 am

In the designer you must put the appropriate {{ }} around your state variables. They are missing from the first screenshot. To answer the second question you can create a server variable that tracks the states of the buttons like {{button_state}} and set its value to 1, 2, 3, 4 in the server commands for each of the buttons via SetVariable|button_state~1 or 2 or 3 or 4.

Then each button will reference the same state variable {{button_state}}. The difference being that the "ON" value for each button would be 1 or 2 or 3 or 4.

Following this logic will accomplish each button lighting up appropriately as they get pushed.

Return to “myServer Apps”

Who is online

Users browsing this forum: No registered users and 1 guest