blinking |
http://www.hscripts.com/scripts/JavaScr ... sition.php
blinking
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
Re: Cursor (not mouse) position
Re: Cursor (not mouse) position
Re: Cursor (not mouse) position
CKEDITOR.plugins.add( 'cursorpos', { init : function( editor ) { editor.on( 'contentDom', function() { this.document.on( 'keypress', function() { var dummyElement = editor.document.createElement( 'img', { attributes : { src : 'null', width : 0, height : 0 } }); editor.insertElement( dummyElement ); var x = 0; var y = 0; var obj = dummyElement.$; while (obj.offsetParent){ x += obj.offsetLeft; y += obj.offsetTop; obj = obj.offsetParent; } x += obj.offsetLeft; y += obj.offsetTop; window.parent.document.title = "top: " + y + ", left: " + x; dummyElement.remove(); }); }) } });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)
CKEDITOR.plugins.add( 'cursorpos', { init : function( editor ) { editor.on( 'contentDom', function() { this.document.on( 'keyup', function() { var dummyElement = editor.document.createElement( 'img', { attributes : { src : 'null', width : 0, height : 0 } }); editor.insertElement( dummyElement ); var x = 0; var y = 0; var obj = dummyElement.$; // Get offSetPos from IFrame-->Up var el = parent.frames[0].frameElement; while (el){ x += el.offsetLeft; y += el.offsetTop; el = el.offsetParent; } // Get offSetPos from IFrame-->Down[/b] while (obj.offsetParent){ x += obj.offsetLeft; y += obj.offsetTop; obj = obj.offsetParent; } // Account for left/right scrolling var scrollTop = editor.document.$.documentElement.scrollTop; var scrollLeft = editor.document.$.documentElement.scrollLeft; x += obj.offsetLeft-scrollLeft; y += obj.offsetTop-scrollTop ; window.parent.document.title = "top: " + y + ", left: " + x + xx: " +scrollLeft+ ", yy: " + scrollTop; dummyElement.remove(); }); }) } });Please post any concerns and/or comments you may have.
Regards,
adico