PDA

View Full Version : multiple views


rwilson
12-14-2008, 04:13 AM
I have several views and I currently transition using the visibility attribute. My question is how and where do I set the attribute back to false? My code sets all views to false which seems rather inelegant.

<node id="gController">
<attribute name="appstate" type="string"/>
<attribute name="currstate" type="string"/>

<handler name="onappstate" args="state">

about.setVisible(false);
home.setVisible(false);
support.setVisible(false);

switch(state)
{
case "about":
about.setVisible(true);
this.setAttribute("currstate", "about");
break;
case "home":
home.setVisible(true);
this.setAttribute("currstate", "home");
break;
case "support":
forum.setVisible(true);
this.setAttribute("currstate", "forum");
break;
default:
//Display an error message
break;
}
</handler>
</node>

rcyeager
12-14-2008, 08:15 AM
Constraints are easier IMO:


<canvas>
<attribute name="appstate" type="string" value="myview1"/>

<view name="myview1" visible="${canvas.appstate == 'myview1'}"/>
<view name="myview2" visible="${canvas.appstate == 'myview2'}"/>
<view name="myview3" visible="${canvas.appstate == 'myview3'}"/>
</canvas>


Then, to change the visible screen to myview2 you just canvas.setAttribute("appstate", "myview2")

rwilson
12-14-2008, 08:46 AM
Thanks, this is what I needed. I've seen the quality of your posts and visited your website. You should write a book on laszlo. "Laszlo from novice to expert":)

rcyeager
12-14-2008, 05:31 PM
Thanks for the kind comments!

I'll pass on writing a book. Besides, there's already "Laszlo in Action".