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

Reply via email to