【问题标题】:Get row and column number from mouse coordinates从鼠标坐标中获取行号和列号
【发布时间】:2012-10-10 22:26:16
【问题描述】:

我在浏览器文本编辑器中使用 Ace。

editor.on("mousemove", function (e)
{
  // use clientX clientY to get row and column locations
});

从 clientX clientY 坐标我需要编辑器上的实际行号和列号。

查看 Ace api 但找不到任何相关内容。

你知道我有什么方法可以做到这一点吗?

谢谢

【问题讨论】:

  • 对于任何寻求通用答案的人:<script>function getCursorPosition() { var p;var editor = ace.edit("editor");p = editor.selection.getCursor();} </script>

标签: javascript ace-editor mouse-cursor


【解决方案1】:

找到了。

editor.on("mousemove", function (e)
{
   var position = e.getDocumentPosition();
});

发现它在 chrome 调试器中查看事件对象。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-12-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-13
    • 2015-11-03
    相关资源
    最近更新 更多