简体   繁体   English

在画布外单击时保持画布选择

[英]Keep canvas selection when a click is done outside of the canvas

I have a web page (developed in Vaadin) with multiple components in it.我有一个网页(在 Vaadin 中开发),其中包含多个组件。 In the center, I have a draw2d canvas with items that I can select, drag n drop, remove, etc. Selection gets updated when I click in the canvas, and I want to keep this behavior.在中间,我有一个draw2d画布,里面有我可以选择、拖放、删除等的项目。当我在画布中单击时,选择会更新,我想保持这种行为。

What I need is to prevent clicks outside of the canvas from interacting with the selection.我需要的是防止画布外的点击与选择交互。 An ugly manner to do this is to keep track of the current selection, and when it is de-selected by a click which was not in the canvas, set it back with its tracked value.一种丑陋的方法是跟踪当前选择,当它被不在画布中的点击取消选择时,将其设置回其跟踪值。

I'd love to hear your ideas about this.我很想听听你对此的看法。

Looks like the canvas was "on top" of other components.看起来画布在其他组件的“顶部”。 So in my case putting z-index es so that component.z-index > canvas.z-index resolves the issue.所以在我的情况下,把z-index es 以便component.z-index > canvas.z-index解决这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM