-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hello, greetings to all, I have a ZK application with 5.0.2 version, i have a problem with the ToolbarButton , the the buttons from the bar do not get the focus when i press the TAB button, when i add a textbox in the toolbar, the textbox can get the focus but the toolbar buttons still can't
PD: In the ZK version 3.6.4 i didn't have that problem
Please Help
prueba.zul
<window id="win" title="Prueba" width="500px" use="page.Prueba">
<button label="Foco" onClick="win.foco()"/>
<toolbar id="tb" align="end" style="background:#defeff repeat-x 0 0;padding-top:7px">
<textbox />
<toolbarbutton id="btnGrabar" label="Grabar" image="/img/Save.png"
onClick="win.onClose()" />
<button id="btnIgnorar" label="Ignorar" image="/img/Undo.png"
onClick="win.onClose()" />
<toolbarbutton id="btnSalir" label="Salir" image="/img/Power.png"
onClick="win.onClose()" />
</toolbar>
</window>
Prueba.java
package page;
import org.zkoss.zul.Window;
import org.zkoss.zul.Toolbarbutton;
public class Prueba extends Window {
private Toolbarbutton btnGrabar;
public void onCreate() {
initcomponentes();
}
private void initcomponentes() {
btnGrabar = (Toolbarbutton) getFellow("btnGrabar");
}
public void foco() {
btnGrabar.setFocus(true);
}
}
Hi santiago
You can set tabindex
<window id="win" title="Prueba" width="500px"> <button label="Foco" tabindex="1" /> <toolbar id="tb" align="end" style="background:#defeff repeat-x 0 0;padding-top:7px"> <textbox tabindex="2" /> <toolbarbutton id="btnGrabar" label="Grabar" image="/img/Save.png" tabindex="3" /> <button id="btnIgnorar" label="Ignorar" image="/img/Undo.png" tabindex="4" /> <toolbarbutton id="btnSalir" label="Salir" image="/img/Power.png" tabindex="5" /> </toolbar> </window>
hi, thanks for your answer
i have this button on my .zul
<button id="btnFoco" label="Foco" onClick="win.foco()"/>
<toolbarbutton id="btnGrabar" label="Grabar" image="/img/Save.png"
onClick="win.onClose()" />
<button id="btnIgnorar" label="Ignorar" image="/img/Undo.png"
onClick="win.onClose()" />
<toolbarbutton id="btnSalir" label="Salir" image="/img/Power.png"
onClick="win.onClose()" />
is there any way to send the focus to the toolbarbutton by clicking on the "btnFoco" button which calls the "foco" method.
I tried to do it with this code:
public void foco() {
btnGrabar.setFocus(true);
}
but it doesn't work... please help mee
It cause by below code
if (!jq.nodeName(n, 'button', 'input', 'textarea', 'a', 'select', 'iframe')) return false;
<zk xmlns:w="http://www.zkoss.org/2005/zk/client"> <script type="text/javascript"><![CDATA[ function foco(){ jq("$btnGrabar").focus(); } ]]></script> <button label="Foco" w:onClick="foco();"/> <toolbarbutton id="btnGrabar" label="Grabar"/> </zk>
thanks for the support
the only way is to generate a function which set the focus for each toolbarbutton.
function foco1(){
jq("$btnGrabar").focus();
}
function foco2(){
jq("$btnSalir").focus();
}
is there any way to invoque jquery from java instead of the client side (.zul)
Yes you can use Clients
<zk > <zscript><![CDATA[ public void foco(){ Clients.evalJavaScript("jq('$btnGrabar').focus();"); } ]]></zscript> <button label="Foco" onClick="foco();"/> <toolbarbutton id="btnGrabar" label="Grabar"/> </zk>
I solved this problem this way:
1) put in lang-addon.xml this rows
<component>
<component-name>mytoolbarbutton</component-name>
<extends>toolbarbutton</extends>
<componentclass>MyToolbarButton</component-class>
</component>
2) Extend toolbarbutton
import org.zkoss.zk.ui.IdSpace;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zul.Toolbarbutton;
public class MyToolbarButton extends Toolbarbutton implements IdSpace{
/**
*
*/
private static final long serialVersionUID = 1L;
public MyToolbarButton()
{
this.addEventListener(Events.ON_CREATE, new EventListener<Event>() {
public void onEvent(Event event){
Clients.evalJavaScript("jQuery(\"#" + MyToolbarButton.this.getUuid()+"\").attr(\"href\",\"\");");
Clients.evalJavaScript("jQuery(\"#" + MYToolbarButton.this.getUuid()+"\").attr(\"onclick\",\"return false;\");");
}
});
}
}
3) Use <mytoolbarbutton>
Regards
Luigi
Asked: 2010-05-18 09:04:08 +0800
Seen: 747 times
Last updated: Mar 30 '19