IDEMPIERE-3426:improve tab behavior
add shortcut key for tab navigate
This commit is contained in:
parent
58b92f42fd
commit
841ea60dc5
|
@ -247,7 +247,7 @@ public class AdempiereWebUI extends Window implements EventListener<Event>, IWeb
|
|||
|
||||
keyListener = new Keylistener();
|
||||
keyListener.setPage(this.getPage());
|
||||
keyListener.setCtrlKeys("@a@c@d@e@f@h@n@o@p@r@s@t@z@x@#left@#right@#up@#down@#home@#end#enter^u@u");
|
||||
keyListener.setCtrlKeys("@a@c@d@e@f@h@n@o@p@r@s@t@z@x@#left@#right@#up@#down@#home@#end#enter^u@u@#pgdn@#pgup");
|
||||
keyListener.setAutoBlur(false);
|
||||
|
||||
//create new desktop
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
package org.adempiere.webui.component;
|
||||
|
||||
import org.zkoss.zk.ui.Page;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
import org.zkoss.zul.Tab;
|
||||
import org.zkoss.zul.Tabpanels;
|
||||
|
||||
|
@ -66,4 +68,16 @@ public class Tabbox extends org.zkoss.zul.Tabbox
|
|||
this.isSupportTabDragDrop = isSupportTabDragDrop;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageAttached(Page newpage, Page oldpage) {
|
||||
super.onPageAttached(newpage, oldpage);
|
||||
Events.sendEvent("onPageAttached", this, null);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageDetached(Page page) {
|
||||
super.onPageDetached(page);
|
||||
Events.sendEvent("onPageDetached", this, null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import org.zkoss.zk.ui.Component;
|
|||
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.event.KeyEvent;
|
||||
import org.zkoss.zk.ui.event.SwipeEvent;
|
||||
import org.zkoss.zul.Menuitem;
|
||||
|
||||
|
@ -41,7 +42,7 @@ import org.zkoss.zul.Menuitem;
|
|||
* @author Low Heng Sin
|
||||
*
|
||||
*/
|
||||
public class WindowContainer extends AbstractUIPart
|
||||
public class WindowContainer extends AbstractUIPart implements EventListener<Event>
|
||||
{
|
||||
private static final String ON_DEFER_SET_SELECTED_TAB = "onDeferSetSelectedTab";
|
||||
|
||||
|
@ -73,6 +74,8 @@ public class WindowContainer extends AbstractUIPart
|
|||
protected Component doCreatePart(Component parent)
|
||||
{
|
||||
tabbox = new Tabbox();
|
||||
tabbox.addEventListener("onPageAttached", this);
|
||||
tabbox.addEventListener("onPageDetached", this);
|
||||
tabbox.setSupportTabDragDrop(true);
|
||||
tabbox.setSclass("desktop-tabbox");
|
||||
tabbox.setId("desktop_tabbox");
|
||||
|
@ -433,4 +436,30 @@ public class WindowContainer extends AbstractUIPart
|
|||
public Tabbox getComponent() {
|
||||
return tabbox;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
|
||||
if (event.getTarget() == tabbox && "onPageDetached".equals(event.getName())) {
|
||||
try {
|
||||
SessionManager.getSessionApplication().getKeylistener().removeEventListener(Events.ON_CTRL_KEY, this);
|
||||
} catch (Exception e) {}
|
||||
}else if (event.getTarget() == tabbox && "onPageAttached".equals(event.getName())) {
|
||||
try {
|
||||
SessionManager.getSessionApplication().getKeylistener().addEventListener(Events.ON_CTRL_KEY, this);
|
||||
} catch (Exception e) {}
|
||||
}else if (Events.ON_CTRL_KEY.equals(event.getName())) {
|
||||
KeyEvent keyEvent = (KeyEvent) event;
|
||||
if (keyEvent.isAltKey() && keyEvent.getKeyCode() == KeyEvent.PAGE_UP
|
||||
&& tabbox.getSelectedTab() != null && tabbox.getSelectedTab().getNextSibling() != null) {
|
||||
tabbox.setSelectedTab((org.zkoss.zul.Tab)tabbox.getSelectedTab().getNextSibling());
|
||||
keyEvent.stopPropagation();
|
||||
}else if (keyEvent.isAltKey() && keyEvent.getKeyCode() == KeyEvent.PAGE_DOWN
|
||||
&& tabbox.getSelectedTab() != null && tabbox.getSelectedTab().getPreviousSibling() != null) {
|
||||
tabbox.setSelectedTab((org.zkoss.zul.Tab)tabbox.getSelectedTab().getPreviousSibling());
|
||||
keyEvent.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue