PDA

View Full Version : how to control LzFocus programaticaly on tabslider?


illogic_code
09-07-2006, 07:18 PM
hello,

have anybody any clue of how to control the focus on a tabslider component?

i have this (weird) skeleton of program:

<canvas fontsize="9" proxied="false" debug="true" width="100%" height="100%">
<tabslider name="ts" width="300" height="400">
<tabelement name="te1" selected="true">
<view name="data1">
<edittext name="edt1" text="edt1 text"/>
</view>
</tabelement>
<tabelement name="te2" selected="false">
<view name="data2">
<edittext name="edt2" text="edt2 text"/>
</view>
</tabelement>
</tabslider>

<button x="400" y="0" text="Change select" onclick="canvas.ts.select(canvas.ts.te2);"/>
</canvas>


what i want is, programmaticaly, throw the focus to the edittext on the botton tabelement when i click the button.

if i can access the onstop of the animator of tabelement, perhaps the LzFocus.setFocus() could work... what u guys think? another solution?

thanks in advance!

(i think that i already burned some million brain cells with this problem...)

EvaF
09-07-2006, 11:25 PM
Hi,
method "select" can be overwritten :

<canvas fontsize="9" proxied="false" debug="true" width="100%" height="100%">
<tabslider name="ts" width="300" height="400">
<method name="select" args="k">
<![CDATA[
super.select(k);
if ((typeof k.selected !='undefined')&amp;&amp;(k.selected==true)){
LzFocus.setFocus(k.subviews[0]);
}
]]>
</method>
<tabelement name="te1" selected="true">
<view name="data1">
<edittext name="edt1" text="edt1 text"/>
</view>
</tabelement>
<tabelement name="te2" selected="false" >
<view name="data2" >
<edittext name="edt2" text="edt2 text" />
</view>
</tabelement>
</tabslider>

<button x="400" y="0" text="Change select" onclick="canvas.ts.select(canvas.ts.te2);"/>
</canvas>

illogic_code
09-08-2006, 08:03 AM
thank you for you response EvaF.

but dont worked right on my application, even using the same idea.

here is the code of the function u gave to me but addapted with my application:


<tabslider name="ts" x="0" y="0" width="100%" height="100%" spacing="2" slideduration="1000">
<method name="select" args="k">
<![CDATA[
super.select(k);
if ((typeof k.selected !='undefined')&&(k.selected==true)){
LzFocus.setFocus(k.pnlDados.edtAgencia);
}
]]>
</method>


see? just a little bit diferent.

pnlDados is a LzView.
edtAgencia is an edittext.
k is a tabelement.

weird things is happening.
coz if i just click on the tabs of the tabslider, it change the tabelement but dont focus the edtAgencia. I put it on Debug and see that he finds the rigth component. (Debug.write(k.pnlDados.edtAgencia)).

but... if i click on one button of the form that execute the code above all work fine. The overrided select works and the focus works too.


<button name="btnNovo" x="2" y="0" height="20" width="75" text="Novo" onclick="this.Execute();">
<method name="Execute">
// limpando o XML
classroot.clearRoot(classroot.dsRQ);

classroot.dsRQ.getPointer().addNode("root", "", {sid:sid})
.appendChild(new LzDataElement("request", {command:"insert"}, ""))
.appendChild(new LzDataElement(classroot.classname, "", ""));

classroot.ts.select(classroot.ts.teC);
</method>
</button>


where classroot is derived from window
ts is the tabslider
teC is the tabelement

did u have any ideia of whats going on?


[]'s

Luis

EvaF
09-08-2006, 09:25 AM
Hi,
modify to suit your application:

<canvas fontsize="9" debug="true" width="100%" height="100%">
<tabslider name="ts" width="300" height="400">
<method name="select" args="k">
<![CDATA[
super.select(k);
if ((typeof k.selected !='undefined')&&(k.selected==true)&&(k.name=='te2')){
// if you are setting a concrete focus, the condition cannot be general
LzFocus.setFocus(k.data2.edt2);

}
]]>
</method>
<tabelement name="te1" selected="true">
<view name="data1">
<edittext name="edt1" text="edt1 text"/>
</view>
</tabelement>
<tabelement name="te2" selected="false" >
<view name="data2" onfocus="LzFocus.setFocus(edt2)" focusable="true">
<edittext name="edt20" y="10" text="edt20 text" />
<edittext name="edt2" y="30" text="edt2 text" />
</view>
</tabelement>
</tabslider>

<button x="400" y="0" text="Change select" onclick="canvas.ts.select(canvas.ts.te2);"/>
</canvas>