Hi,
has anyone been able to OR know how to capture the cursor position (blinking |) inside the editor?
I've googled and found a few examples (http://www.hscripts.com/scripts/JavaScr ... sition.php) related to the mouse, but I actually want to capture the cursor itself.
I can capture the keypress event inside the editor, now all I want to do is get the location of the blinking cursor
here is what I have so far...
function keyPressed(event) { if (!event && window.event) event = window.event; if (event) keyPress = (event) ? event.keyCode : event.which; [b] [i]findPositions();[/i][/b] } function findPositions() { var text = editor.document.getBody().getText(); var selection = editor.getSelection(); if (selection) { var selElement = selection.getSelectedElement(); var startElem = selection.getStartElement(); // Internet Explorer var range = selection.getRanges(); var dpl = range.duplicate(); if (range.text.length > 0) { dpl.moveToElementText(area); dpl.setEndPoint("EndToEnd", range); startPosition = dpl.text.length-range.text.length; endPosition = startPosition + range.text.length; } } else { // Mozilla Firefox startPosition = area.selectionStart; endPosition = area.selectionEnd; } }
Re: Cursor (not mouse) position
Re: Cursor (not mouse) position
I find that hard to believe...there is got to be a way to determine the x,y position. ..
Re: Cursor (not mouse) position
Re: Cursor (not mouse) position
I want to create it right underneath the cursor position and have it move to the right as the user types
Re: Cursor (not mouse) position
Gary,
have you had a chance to look at this yet?
anyone?
Re: Cursor (not mouse) position
Re: Cursor (not mouse) position
Re: Cursor (not mouse) position
Re: Cursor (not mouse) position
Re: Cursor (not mouse) position
try subtracting the scrolling position (scrolltop & scrollleft). This will guarantee your tooltip remains inside the editor, but you still need to figure out a way to get the screenX and screenY relative to the parent window.
cheers
yamayra1
Re: Cursor coordinates X,Y (SOLVED)
This example takes into account the IFrame position and also the scrolling position (left/right)
Please post any concerns and/or comments you may have.
Regards,
adico