set cursor position

2,847 views
Skip to first unread message

d3rek

unread,
Feb 6, 2012, 7:30:08 AM2/6/12
to Ajax.org Cloud9 Editor (Ace)
Is there any API to set cursor position?

It's possible to somehow set cursor position based on clientX and
clientY data?

Phrogz

unread,
Mar 2, 2012, 2:43:00 PM3/2/12
to ace-d...@googlegroups.com
On Monday, February 6, 2012 5:30:08 AM UTC-7, d3rek wrote:
Is there any API to set cursor position?

Does not appear to be, based on the source for selection.js.
 
It's possible to somehow set cursor position based on clientX and
clientY data?

Looks like you can perform a reach-around:

editor.getSession().getSelection().selectionLead.setPosition(2,3);

Juliusz Gonera

unread,
Mar 3, 2012, 1:30:42 AM3/3/12
to ace-d...@googlegroups.com
Phrogz wrote:
> On Monday, February 6, 2012 5:30:08 AM UTC-7, d3rek wrote:
>
> Is there any API to set cursor position?
>
>
> Does not appear to be, based on the source for selection.js
> <https://github.com/ajaxorg/ace/blob/master/lib/ace/selection.js>.

What about editor.moveCursorTo() and moveCursorToPosition()?

--
Juliusz Gonera
http://juliuszgonera.com/

Phrogz

unread,
Mar 3, 2012, 1:31:12 PM3/3/12
to ace-d...@googlegroups.com
On Friday, March 2, 2012 11:30:42 PM UTC-7, Juliusz Gonera wrote:
Phrogz wrote:
> On Monday, February 6, 2012 5:30:08 AM UTC-7, d3rek wrote:
> > Is there any API to set cursor position?
> Does not appear to be, based on the source for selection.js
> <https://github.com/ajaxorg/ace/blob/master/lib/ace/selection.js>.

What about editor.moveCursorTo() and moveCursorToPosition()?

Whoops, I totally missed that. (Why on earth is the API for getting the cursor position buried deep, but set cursor is at the top level, not even on the session?)

Harutyun Amirjanyan

unread,
Mar 3, 2012, 2:11:06 PM3/3/12
to ace-d...@googlegroups.com
>Why on earth is the API for getting the cursor position buried deep
see editor.getCursorPosition and editor.getSelectionRange

>It's possible to somehow set cursor position based on clientX and clientY data?

there is editor.renderer.screenToTextCoordinates to get row,column
from pageX,pageY

Reply all
Reply to author
Forward
0 new messages