OpenLayers 弹出窗口中的 qx.ui.root.Inline contentDiv =>按钮无法点击!

发布于 2024-09-29 23:37:51 字数 2822 浏览 5 评论 0原文

我正在开发一个集成 OpenLayers 和 Qooxdoo 的项目......到目前为止我取得了很大的成功。但现在我希望能够将 qooxdoo 小部件放置在 OpenLayers 弹出窗口中(本例中为 FramedCloud),但发生了一些奇怪的事情 - 按钮无法单击!

悬停事件似乎正在工作,并且我已经确定 qx.event.handler.Focus.__onNativeMouseDown 正在执行,因此单击事件似乎正在进入 qooxdoo 事件系统(?),但是 qx.event.handler .Mouse._onButtonEvent 永远不会被调用!

要么是 OL 中有什么问题,要么是我做错了什么。请参阅以下一个或两个链接来获取测试用例:

http://s89238293.onlinehome.us/olisletest/build/index.html http://s89238293.onlinehome.us/olisletest/source/index.html

(请注意,“源”链接加载 qooxdoo OpenLayers 的未压缩/调试版本,因此需要一段时间才能加载!)

上面的链接建立在sketch qx 内联应用程序,这是代码的主要自定义部分:

  var map = new OpenLayers.Map("map_canvas", {
      projection: new OpenLayers.Projection("EPSG:900913"),
      displayProjection: new OpenLayers.Projection("EPSG:4326"),
      units: "m",
      numZoomLevels: 18,
      maxResolution: 156543.0339,
      maxExtent: new OpenLayers.Bounds(-20037508, -20037508,
                                       20037508, 20037508.34)
  });

  map.addLayer(new OpenLayers.Layer.OSM());

  map.setCenter(new OpenLayers.LonLat(-97.0, 38.0).transform(map.displayProjection, map.projection), 3);

  var popup = new OpenLayers.Popup.FramedCloud(
          "searchSelection",
          new OpenLayers.LonLat(-97.0, 38.0).transform(map.displayProjection, map.projection),
          new OpenLayers.Size(200, 200),
          null,
          null,
          true,
          null
  );
  popup.autoSize = false;
  map.addPopup(popup);

  var button2 = new qx.ui.form.Button("A Button");
  button2.addListener("execute", function(){alert("Hello???");}, this);

  var isle = document.createElement("DIV");
  popup.contentDiv.appendChild(isle);
  var popupIsle = new qx.ui.root.Inline(isle, false, false);
  popupIsle.setLayout(new qx.ui.layout.VBox);
  popupIsle.setBackgroundColor("#fff");
  popupIsle.add(button2);

任何人都可以帮我弄清楚点击事件发生了什么?


== EDIT ==

谢谢亚历克斯,我做了更多的尝试来尝试找出答案。

我在 OL 地图之外尝试了基本上相同的代码的测试,它有效,因此被消除了。

除了 OL 弹出对象之外,我还执行了此操作:

popup.events.un({
  "mousedown": popup.onmousedown,
  "mousemove": popup.onmousemove,
  "mouseup": popup.onmouseup,
  "click": popup.onclick,
  "mouseout": popup.onmouseout,
  "dblclick": popup.ondblclick,
  scope: popup
});

我认为这会禁用弹出窗口本身的所有事件处理(请注意,例如,您现在可以通过在弹出窗口内拖动来平移地图 - 这是次优的,但证明了这一点)。而且,这没有帮助......这似乎表明地图本身的事件处理可能正在阻止事件。由于显而易见的原因,我无法禁用地图上的鼠标事件。

我将把这个传递给 OpenLayers 邮件列表,希望能得到更多帮助......但与此同时,有人对解决方法有任何想法吗?对我来说很奇怪的是,某些事件(鼠标悬停)工作正常,但单击却不行。此时我什至对黑客持开放态度。

另外,我在调试这个时遇到了很大的困难...我尝试使用 Firebug(和 Safari 调试器)中的“Break on Next”功能,但由于 qooxdoo 在内部运行多个间隔计时器,所以我无法捕获点击,因为噪音(间隔代码总是在我点击之前出现)。任何有关如何在调试器中捕获单击事件的提示将不胜感激!

I'm working on a project that integrates OpenLayers and Qooxdoo...so far I'm having lots of success. But now I want to be able to place qooxdoo widgets in an OpenLayers popup (FramedCloud in this case) and something weird is happening--the button won't click!

The hover events seem to be working, and I've determined that qx.event.handler.Focus.__onNativeMouseDown is being executed, so the click event seems to be getting to the qooxdoo event system (?), but qx.event.handler.Mouse._onButtonEvent never gets called!

Either something in OL is getting in the way, or I'm doing something wrong. See one or both of these links for a test case:

http://s89238293.onlinehome.us/olisletest/build/index.html
http://s89238293.onlinehome.us/olisletest/source/index.html

(be advised that the "source" link loads the uncompressed/debug versions of both qooxdoo and OpenLayers, so it takes a while to load!)

The links above build on the skeleton qx Inline app, here's the main custom part of the code:

  var map = new OpenLayers.Map("map_canvas", {
      projection: new OpenLayers.Projection("EPSG:900913"),
      displayProjection: new OpenLayers.Projection("EPSG:4326"),
      units: "m",
      numZoomLevels: 18,
      maxResolution: 156543.0339,
      maxExtent: new OpenLayers.Bounds(-20037508, -20037508,
                                       20037508, 20037508.34)
  });

  map.addLayer(new OpenLayers.Layer.OSM());

  map.setCenter(new OpenLayers.LonLat(-97.0, 38.0).transform(map.displayProjection, map.projection), 3);

  var popup = new OpenLayers.Popup.FramedCloud(
          "searchSelection",
          new OpenLayers.LonLat(-97.0, 38.0).transform(map.displayProjection, map.projection),
          new OpenLayers.Size(200, 200),
          null,
          null,
          true,
          null
  );
  popup.autoSize = false;
  map.addPopup(popup);

  var button2 = new qx.ui.form.Button("A Button");
  button2.addListener("execute", function(){alert("Hello???");}, this);

  var isle = document.createElement("DIV");
  popup.contentDiv.appendChild(isle);
  var popupIsle = new qx.ui.root.Inline(isle, false, false);
  popupIsle.setLayout(new qx.ui.layout.VBox);
  popupIsle.setBackgroundColor("#fff");
  popupIsle.add(button2);

Can anyone help me figure out what's happening to the click event?


== EDIT ==

Thanks Alex, I've done some more plugging at it to try and figure out.

I tried a test of essentially the same code outside the OL map and it works, so that's eliminated.

I did this additionally to the OL popup object:

popup.events.un({
  "mousedown": popup.onmousedown,
  "mousemove": popup.onmousemove,
  "mouseup": popup.onmouseup,
  "click": popup.onclick,
  "mouseout": popup.onmouseout,
  "dblclick": popup.ondblclick,
  scope: popup
});

Which I think disables all event handling on the popup itself (notice, for example, you can now pan the map by dragging within the popup--which is suboptimal, but proves the point). And, that didn't help...which seems to suggest that perhaps the event handling on the map itself is blocking the events. I can't disable mouse events on the map, for obvious reasons.

I'm going to pass this on to the OpenLayers mailing list in hopes of some more help...but in the meantime, anyone have any ideas for a workaround? So strange to me that some events (mouseover) work fine, but click doesn't. I'm open even to hacks at this point.

Also, I'm having a real hard time debugging this...I tried using the "Break on Next" feature in Firebug (and Safari debugger), but since qooxdoo is running several interval timers internally I can't catch the click because of the noise (the interval code always comes up before I can click). Any tips on how to catch the click event in the debugger would be appreciated!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

許願樹丅啲祈禱 2024-10-06 23:37:51

我也有同样的问题。单击 Qooxdoo 不起作用。我使用 Qooxdoo v1.6 和 OpenLayers v2.12。问题是弹出窗口和地图导航器上的 mousedown 事件。就我而言,以下内容运行良好:

// looking for the navigation control of the map
var controls = map.controls;
var navigator;
for(var i = 0; i < controls.length; i++) {
    if(controls[i].CLASS_NAME == "OpenLayers.Control.Navigation")
        navigator = controls[i];
}

popup.events.unregister("mousedown", popup, popup.onmousedown); // disable the mousedown-event
popup.events.register("mouseover", navigator, navigator.deactivate()); // on mouseover: deactivate the navigation-control of the map
popup.events.register("mouseout", navigator, navigator.activate()); // on mouseout: activate the navigation-control of the map

我希望这对任何人都有帮助。

I had the same problem. Clicking on the Qooxdoo doesn't work. I use Qooxdoo v1.6 and OpenLayers v2.12. The Problem was the mousedown-event on the popup and the Map-Navigator. In my case the following has working fine:

// looking for the navigation control of the map
var controls = map.controls;
var navigator;
for(var i = 0; i < controls.length; i++) {
    if(controls[i].CLASS_NAME == "OpenLayers.Control.Navigation")
        navigator = controls[i];
}

popup.events.unregister("mousedown", popup, popup.onmousedown); // disable the mousedown-event
popup.events.register("mouseover", navigator, navigator.deactivate()); // on mouseover: deactivate the navigation-control of the map
popup.events.register("mouseout", navigator, navigator.activate()); // on mouseout: activate the navigation-control of the map

I hope, this would be helpful for anybody.

吲‖鸣 2024-10-06 23:37:51

我刚刚测试了您的示例,我认为层实现正在阻止单击事件。所以点击事件首先由OpenLayers处理,qooxdoo没有得到它。

请确保 qooxdoo 的内联实现没有任何问题。您是否已经在不包含 OpenLayers 内容的情况下测试了内联按钮?如果在没有 OpenLayers 实现的情况下一切正常,您至少知道 OpenLayers 以某种方式阻止了事件。

这将是我调试的第一步。希望能有所帮助。

问候,
亚历克斯

I've just tested your example and I think that the layer implementation is blocking the click event. So the click event is first processed by the OpenLayers and qooxdoo does not get it.

Do be sure that nothing is wrong with inline implementation of qooxdoo. Do you already tested your inline button without including the OpenLayers stuff? If everything is working fine without OpenLayers implementation you know at least that OpenLayers is somehow blocking the events.

This would be my first step in debugging. Hope that helps a bit.

Regards,
Alex

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文