如何找到鼠标光标索引

发布于 2024-09-17 12:18:37 字数 86 浏览 3 评论 0原文

您好,我用“undotext”小部件编写了一个脚本, 我正在寻找一种方法来获取鼠标光标所在位置的行索引。

类似地,当用户选择了该行的一部分时。

Hi I wrote a script with the "undotext" widget,
and I'm looking for a way to get the line index of the palce where the mouse cursor is standing.

and similarly when the user has select part of the line.

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

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

发布评论

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

评论(1

厌味 2024-09-24 12:18:45

要获取鼠标光标在文本坐标(不仅仅是x,y)中的当前位置,您需要执行以下操作之一:

$txt->index("current");

或这样做(其中$x$y 给出鼠标光标位置相对于文本小部件):

$txt->index("@$x,$y");

第一个肯定更方便,但如果您在拖动过程中则需要第二个(<当按下任何鼠标按钮时,code>current 标记不会更新)。

To get the current location of the mouse cursor in text coordinates (not just x,y) you need to do either this:

$txt->index("current");

or this (where $x and $y give the mouse cursor location relative to the text widget):

$txt->index("@$x,$y");

The first is definitely more convenient, but the second is needed if you're in the middle of a drag (the current mark isn't updated while any mouse button is down).

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