how do I handle double-clicking?

343 views
Skip to first unread message

costa

unread,
Dec 22, 2014, 6:46:49 PM12/22/14
to ace-d...@googlegroups.com
Hello:

This may be simple but I haven't been able to find how I can handle the double-clicking event on a line.

I use two instances of the editor, one is for output error messages. When the user double-clicks on an error I want to jump to the position in the other editor where the error occurred. I will have to get the line the user clicked on, extract the position using regular expressions and then move the cursor to that position in the first editor. I don't know exactly how to wire the double-click event, also, is there a function that gives me for the given coordinates (x, y) the line # at that coordinate in the editor view?

Thanks


costa

unread,
Dec 22, 2014, 7:59:12 PM12/22/14
to ace-d...@googlegroups.com
Figured it out myself.

editor.on('dblclick', function() {
alert('Current line is ' + editor.getCursorPosition().row);
});

I am still curious about my other question, if there is an api to detect the line at coordinates (x, y)... There are some functions (EditSession.documentToScreenPosition and co ) but they don't do exactly this...

I am going to use the editor.getCursorPosition().row for now...


Harutyun Amirjanyan

unread,
Dec 23, 2014, 5:51:22 AM12/23/14
to ace-d...@googlegroups.com
you can use 

editor.on('dblclick', function(ev) {
   ev.getDocumentPosition().row;
   ev.stop()
})

editor.getCursorPosition() should work too, since cursor is moved to clicked position on mousedown


costa

unread,
Dec 23, 2014, 2:31:45 PM12/23/14
to ace-d...@googlegroups.com
FYI, I get a 404 when I try to access the link from your post...

Harutyun Amirjanyan

unread,
Dec 23, 2014, 5:19:17 PM12/23/14
to ace-d...@googlegroups.com
sorry the correct link is https://github.com/ajaxorg/ace/blob/v1.1.8/lib/ace/mouse/default_handlers.js#L193 with dots instead of commas.
Reply all
Reply to author
Forward
0 new messages