Dear Jarry,
thx a lot, but seems this is just working, when inserting text into empty editor.
When editor already filled and I click on any position inside the text there, then my function properly inserts the text at this position, but I dont get the cursor after the inserted text in this case (its always in beginning of all text in line 1, pos 1...).
Please for a final hint to get this up & running & done
))) THX!
Or how would a GetCursor/SetCursor, respectively GetSelectedText/SelectText function have toi look in general?
function InsertText(txt)
{
var str = $('#myTextEditor').texteditor('getValue').trim();
logconsole("str=["+str+"] len=["+str.length+"]");
if ( (!str) || (str.length < 1 ) )
{
// THIS part WORKS... cursor is set after the inserted TEXT
logconsole("Editor empty");
$('#myTextEditor').texteditor('getEditor').focus();
$('#myTextEditor').texteditor('getEditor').trigger('mouseup');
$('#myTextEditor').texteditor('insertContent', '<span>'+txt+'</span>');
$('#myTextEditor').texteditor('options').selectedRange.collapse(false);
}
else
{
// DOES NOT WORK... TEXT inserted properly at actual cursor, but focus always goes to line1, pos1 in the beginning of all text in the texteditor
logconsole("Editor filled, inserting at actual cursor position");
$('#myTextEditor').texteditor('insertContent', '<span>'+txt+'</span>');
$('#myTextEditor').texteditor('getEditor').focus();
//$('#myTextEditor').texteditor('getEditor').trigger('mouseup');
$('#myTextEditor').texteditor('options').selectedRange.collapse(false);
}
return true;
}