Thanks for investigating this further! When I wrote my "this is a
bug" message, I confess I hadn't gone back through the code to verify
whether it had been designed to do what Tim was expecting.
I really like the suggestion that tabslider should have a mechanism
whereby the currently selected tab has a chance to veto a change in
selection. I think extending tabslider itself to do this would be
relatively straightforward, potentially even simpler than the
external solution you found below.
In fact, this problem isn't unique to tabslider -- it is common to
tabslider, tabs, and any other similar component such as a wizard
interface controller. I could imagine a screen-management (base-)
class that would manage screen switches through the protocol you
suggested, and perhaps even handle initstage so that screens were
built only when needed (another issue we want to address with this
type of component).
Let's at least add this thread to the bug in JIRA (http://
www.openlaszlo.org/jira/browse/LPP-1057). Of course, if you would
like to contribute a more complete proposal to address this within
the components themselves, I know I'd be interested in seeing it!
jim
On Nov 23, 2005, at 3:32 PM, Papadogiannakis Vagelis wrote:
I deleted all your comments to save some bandwidth
As expected, the movement of the tabslider has begun when you check
for the constraint that would cancel the selection.
(this is why you see the combo for a small period of time and then
it dissapears)
Actually, your code is NOT canceling the selection of the second
tabelement, it just selects the first again, but you cannot stop
the movement of the slider!.
Now, if you had a slideduration of 0, this wouldnot have happened
(try it to see for yourself).
This is still a bug, but it is kind of expected behavior...
The basetabslider should have an event of "ondeselect", with an
argument of the tabelement that is deselected, and an attribute
"cancelselection" to cancel the selection.
This is explained by the following code:
---
<canvas width="1024" height="768">
<tabslider width="800" height="600" oninit="selectItemAt(0)">
<method event="ondeselected" args="tabelement">
// you should check here if the "tabelement" arg is what
you want, or else it will
// happen on every tab you deselect
if(questions.listofthings.getValue() == "Item 1") {
questions.setAttribute("selected","true");
this.setAttribute('cancelselection', true);
}
</method>
<attribute name="old_slideduration" type="number"
value="$once{this.slideduration}" />
<tabelement text="Questions" id="questions">
<combobox oninit="selectItemAt(0)" name="listofthings">
<textlistitem text="Item 1"></textlistitem>
<textlistitem text="Item 2"></textlistitem>
<textlistitem text="Item 3"></textlistitem>
</combobox>
</tabelement>
<tabelement text="Results">
<text>Bob</text>
</tabelement>
</tabslider>
</canvas>
---
and this is finally the solution you were looking for:
<canvas width="1024" height="768">
<class name="SREtabslider" extends="tabslider">
<attribute name="deselected" value="null" type="expression" />
<attribute name="ondeselected" />
<attribute name="cancelselection" type="boolean"
value="false" />
<method name="openTab" args="tabelement,withAnimation" >
var didopen = false;
var ot = this._selector.getSelection()[0];
if ( ot != tabelement ){
if (this.ondeselected){
this.deselected=ot;
this.ondeselected.sendEvent(ot);
}
if (this.cancelselection){
this.setAttribute('cancelselection', false);
return;
}
this._selector.select(tabelement);
this.opennedtab = tabelement;
didopen = true;
}
return didopen;
</method>
</class>
<SREtabslider width="800" height="600" oninit="selectItemAt(0)">
<method event="ondeselected" args="A">
if (A.name == "questions"){
if(questions.listofthings.getValue() == "Item 1") {
questions.setAttribute("selected","true");
this.setAttribute('cancelselection', true);
}
}
</method>
<attribute name="old_slideduration" type="number"
value="$once{this.slideduration}" />
<tabelement text="Questions" id="questions" name="questions">
<combobox oninit="selectItemAt(0)" name="listofthings">
<textlistitem text="Item 1"></textlistitem>
<textlistitem text="Item 2"></textlistitem>
<textlistitem text="Item 3"></textlistitem>
</combobox>
</tabelement>
<tabelement text="Results">
<text>Bob</text>
</tabelement>
</SREtabslider>
</canvas>
--
Vagelis Papadogiannakis
Any comments, suggestions, flames, questions, direct the to me!
PS: I do extend laszlo assets in various ways, it took me about 30
minutes to do this one.
If you have a large laszlo app you want to create, do hire me... I
could use your money ;)
Thank you.
_______________________________________________
Laszlo-user mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-user