diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/AdempiereWebUI.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/AdempiereWebUI.java index 39e4ed5b03..a8bf29deeb 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/AdempiereWebUI.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/AdempiereWebUI.java @@ -247,7 +247,7 @@ public class AdempiereWebUI extends Window implements EventListener, 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 diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/Tabbox.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/Tabbox.java index 7ff4277a9f..81d82dcc9d 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/Tabbox.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/component/Tabbox.java @@ -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); + } } diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/part/WindowContainer.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/part/WindowContainer.java index a6090de566..01bb179aba 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/part/WindowContainer.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/part/WindowContainer.java @@ -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 { 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(); + } + } + + } }