This will be needed to fix
SRC-55.
Detecting the cursor location is easy in Firefox, but it seems to be especially tricky in IE6; it's actually causing the Dojo code to break in Selenium because we're not specifying the cursor location, which we probably should.
Here's some sample code for IE:
http://the-stickman.com/web-development/javascript/finding-selection-cursor-position-in-a-textarea-in-internet-explorer/
Here's the code from Dojo's "dojo.widget.html.ComboBox" (which breaks in IE6 when there is no cursor in position):
getCaretPos: function(element){
// FIXME: we need to figure this out for Konq/Safari!
if(dojo.render.html.mozilla){
// FIXME: this is totally borked on Moz < 1.3. Any recourse?
return element.selectionStart;
}else if(dojo.render.html.ie){
// in the case of a mouse click in a popup being handled,
// then the document.selection is not the textarea, but the popup
// var r = document.selection.createRange();
// hack to get IE 6 to play nice. What a POS browser.
// var tr = r.duplicate();
var tr = document.selection.createRange().duplicate();
// var ntr = document.selection.createRange().duplicate();
var ntr = element.createTextRange();
// FIXME: this seems to work but I'm getting some execptions on reverse-tab
tr.move("character",0);
ntr.move("character",0);
/*
try{
ntr.moveToElementText(element);
}catch(e){ dojo.debug(e); }
*/
ntr.setEndPoint("EndToEnd", tr);
return String(ntr.text).replace(/\r/g,"").length;
}
}
setting the cursor location seems to be a bit more straightforward:
http://www.faqts.com/knowledge_base/view.phtml/aid/15728