gpt4 book ai didi

java - 如何获得相对和绝对光标位置?

转载 作者:行者123 更新时间:2023-11-29 03:30:52 25 4
gpt4 key购买 nike

如何使用 SWT 获取光标的当前位置

我需要:

  1. 绝对位置(仅相对于当前Display)
  2. 当前 Activity 控件相对位置

最佳答案

获取光标位置相对于当前显示:

import org.eclipse.swt.widgets.Display;
[...]
Point cursorLocation = Display.getCurrent().getCursorLocation();


要获得相对于焦点控件的位置,您必须翻译它:

import org.eclipse.swt.widgets.Display;
[...]
Point cursorLocation = Display.getCurrent().getCursorLocation();
Point relativeCursorLocation = Display.getCurrent().getFocusControl().toControl(cursorLocation);

关于java - 如何获得相对和绝对光标位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18356516/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com