模拟mousemove事件

时间:2013-07-10 15:17:39

标签: qooxdoo

当光标在地图上移动时,qooxdoo中的“mousemove”文档侦听器在最新版本的OpenLayers(2.13和2.13.1)中被阻止。我认为我可以通过听OpenLayers“mousemove”监听器来绕过这个,只是模拟一个基于此的mousemove事件,但他们的事件与qooxdoo正在寻找的不同。所以我尝试使用qx.event.type.Mouse()来模拟mousemove事件;它部分工作但打破了地图平移功能并抛出此错误(Uncaught TypeError:无法读取未定义鼠标的属性'pageX' - 第229行)。有什么建议吗?

// OpenLayers mousemove Listener
var events = me.map.events;
events.register("mousemove",me.map, function(e){
        var e = new qx.event.type.Mouse();
        console.log("Attempt to make a Qooxdoo mouse position at OpenLayers location", e);
        me.mouseoverPopup.placeToMouse(e);
        return true;
},true); 

// Qooxdoo document mousemove listener
//   ** this was my old standard but OL 2.13 blocks this from occurring when
//      I move over the map.
qx.bom.Element.addListener(document, "mousemove", function(e)
{         
   me.mouseoverPopup.placeToMouse(e);         
}, this);

1 个答案:

答案 0 :(得分:1)

qooxdoo的鼠标事件需要使用本机事件对象进行初始化,以获取鼠标坐标和其他信息。试试这个:

events.register("mousemove",me.map, function(e){
        var qxE = new qx.event.type.Mouse();
        qxE.init(e);
        console.log("Attempt to make a Qooxdoo mouse position at OpenLayers location", e);
        me.mouseoverPopup.placeToMouse(qxE);
        return true;
},true);