当我只有坐标x和y时,我正在swt(eclipse平台)中寻找方法或其他东西来获得Control。我只找到了这个
Display.getDefault().getCursorControl();
但这不是我想要的。我想要类似的getControlByCoordinates(int x,in y)。
没有这样的方法通过坐标返回Control
。
你需要
- 获取活动
Shell
- 递归遍历所有子项(
Control
s) - 在每个
Control
上调用getBounds()
- 检查您的
Point
是否与Rectangle
相交