我想在zk中处理MOUSE事件滚动但无法找到它。我可以使用Java Script来实现,但我想将通知发送到服务器端,以便服务器可以将数据发送回客户端。有没有办法在Controller中获取该事件。或者做
comp.addEventListener(EVENTNAME,mylistener);
我想知道上面EVENTNAME的值是什么。
谢谢, 阿曼
答案 0 :(得分:3)
据我所知,ON_SCROLL事件仅在项目有滚动条时才有效;如果你想捕获mousewheel事件,你需要在javascript中执行此操作,并创建自己的事件。
这就是我在寻呼网格中捕获鼠标滚动以使用鼠标滚轮推进页面所做的工作;将通知发送到服务器端的部分是以下行:this.getPaginal()。fire('onPaging',nextPage)
<zk>
<zscript>Object[] o = new String[150];
</zscript>
<hlayout id="layout" vflex="1" hflex="1">
<grid id="grid1" width="300px" autopaging="true" height="300px" mold="paging" vflex="true">
<rows>
<row forEach="${o }">
<label value="item ${forEachStatus.index}"/>
</row>
</rows>
</grid>
</hlayout>
<zscript><![CDATA[
{
grid1.setWidgetOverride("bind_", "function(){\r\n"+
"this.$supers('bind_', arguments);\r\n"+
"var node = this.$n();\r\n"+
"if (node.addEventListener)\r\n"+
" node.addEventListener('DOMMouseScroll', this.proxy(this.onMouseWheel), false);\r\n"+
"node.onmousewheel = this.proxy(this.onMouseWheel);\r\n"+
"}");
grid1.setWidgetOverride("onMouseWheel",
"function(event){\r\n" +
" var delta = 0;\r\n" +
" if (!event) /* For IE. */ \r\n" +
" event = window.event;\r\n" +
" if (event.wheelDelta) { /* IE/Opera. */\r\n" +
" delta = event.wheelDelta / 120;\r\n" +
" if (window.opera) \r\n" +
" delta = -delta;\r\n" +
" }\r\n" +
" else \r\n" +
" if (event.detail) {\r\n" +
" delta = -event.detail / 3;\r\n" +
" }\r\n" +
" if (delta) {\r\n" +
" console.log('delta = ' + delta); " +
" var currPage = this.getPaginal().getActivePage(); \r\n" +
" var nextPage = Math.min (this.getPageCount() - 1, Math.max (0, currPage - delta)); \r\n" +
" this.getPaginal().fire('onPaging', nextPage);\r\n" +
" }\r\n" +
" if (event.preventDefault) \r\n" +
" event.preventDefault();\r\n" +
" event.returnValue = false;\r\n" +
"} ");
}
]]></zscript>
答案 1 :(得分:0)
尝试org.zkoss.zk.ui.event.Events.ON_SCROLL或org.zkoss.zk.ui.event.Events.ON_SCROLLING。