-
All replies
-
Helpful answers
-
May 23, 2014 9:23 AM in response to science_01by jkahn117,In order to achieve this functionality, you could extend our earlier example and utilize the ViewController itself to coordinate when arrows appear/disapper.
For each switch, changing the passed string per switch (essentially an id for the switch or you could use the switch outlet's id):
this.onControlValueChange = function (event) { this.viewController.switchChanged("switch1", this.on); };Then in the ViewController for the widget, you would check which switches are on to determine if an arrow should be shown.
this.switchChanged = function(switchId, state) { if (state == true) { // check if paired switch is also on; if so, show arrow // you will need to think through how to manage the state of multiple switches } };You may also consider adding a reset button or additional logic that ensures only two switches are on at a time.
-
May 23, 2014 10:34 AM in response to jkahn117by science_01,Hello jkahn117, thank you for your response.
So, I understand the first part about passing the string for each switch.
this.onControlValueChange = function (event) {
this.viewController.switchChanged("switch1", this.on);
};
However, I'm confused about how to combine these into an action:
What is the location of the ViewControler for the widget?
Also, what is the syntax for the instructions below? eg What is the code to check for paired switches?
// check if paired switch is also on; if so, show arrow
again, thank you very much I certainly appreciate your responses.
-
May 23, 2014 12:18 PM in response to science_01by jkahn117,The ViewController is the widget itself (called Page 1 in iAd Producer). Just click the Code button with the page selected.
Without knowing more about your widget, it is hard to detail an exact solution. For example, are there two specific switches that should be on at a given time (e.g. is the widget intended to ask a question) or can the user just toggle switches randomly to turn on arrows? Either way, you will need some way to track the state of each switch (on/off) as well as which combinations turn on which arrows.
My earlier answer simply guides on how to let the Page know that a switch has been turned on or off, that should be the basis for the more complex logic you will need to switch on the arrows.
-
May 23, 2014 12:41 PM in response to jkahn117by science_01,For example, are there two specific switches that should be on at a given time (e.g. is the widget intended to ask a question) or can the user just toggle switches randomly to turn on arrows?
Exactly this, as you stated. The arrow should only display after two switches have been activated. For instance, toggling switch1 without switch2 "on" does not display an arrow, but if switch2 is "on" when switch1 is toggled then the arrow displays on the drawing.
I'm hoping to present diagnostic cases, and as I speak my classmates will toggle the switches based on how the patient presents. So, for example, during the talk I give two hints (hint1 and hint2) for diagnosis1, and the user toggles switch1 and switch2 and arrow1 displays at location1. However, later in the talk I give two hints (hint1 and hint3) for diagnosis2, and the user toggles switch1 and switch3 with arrow2 displaying at location2.
as before, i more than appreciate all the help. if i could buy you a beer i would.