如何获得坐标控制-eclipse平台



当我只有坐标x和y时,我正在swt(eclipse平台)中寻找方法或其他东西来获得Control。我只找到了这个

Display.getDefault().getCursorControl();

但这不是我想要的。我想要类似的getControlByCoordinates(int x,in y)。

没有这样的方法通过坐标返回Control

你需要

  1. 获取活动Shell
  2. 递归遍历所有子项(Control s)
  3. 在每个Control上调用getBounds()
  4. 检查您的Point是否与Rectangle相交

最新更新