Cursor focus after formatting text in Firefox [message #33954] |
Thu, 28 September 2006 16:54 |
Ernesto
Messages: 413 Registered: August 2005
Karma: 0
|
Senior Member |
|
|
If you write a bunch of text, and want to apply text formating, for example the [b][/b] code around, lets say a "headline" then after highlighting the selected text and clicking the button, the cursor will pop down to the end of your text, which if you have a long post and want to make lots of formatting, is very very annoying.
I searched the forum for tweaks or fixes, where you at one point pointed out that you had the "focus problem fixed in CVS" but it didn't apply to this problem. The problem exists on your version of fudforum as well (fudform.org) - The cursor works in IE (you highlight text, format it, and cursor ends up at the end of the word(s) instead of at the end of the entire text.
Ginnunga Gaming
|
|
|
Re: Cursor focus after formatting text in Firefox [message #33962 is a reply to message #33954] |
Fri, 29 September 2006 14:22 |
Ilia
Messages: 13241 Registered: January 2002
Karma: 0
|
Senior Member Administrator Core Developer |
|
|
I've checked 3 browsers so far:
Firefox, Safari and Opera and it works fine in those 3, the cursor position is placed before the highlighted text.
In IE 6 the cursor position remains around the selected text and is placed where you click your mouse after.
So in my tests on 4 browsers I do see a problem.
FUDforum Core Developer
|
|
|
Re: Cursor focus after formatting text in Firefox [message #33991 is a reply to message #33954] |
Sat, 30 September 2006 23:05 |
Ernesto
Messages: 413 Registered: August 2005
Karma: 0
|
Senior Member |
|
|
Make a long post (one that forces your edit window to scroll) - Then go somewhere in the middle, highlight a word, make it bold - observe that the scrollwindow will move to the top, and your cursor will move to the end of the text. Perhaps it's a firefox setting, but many of my users experience the same problem. (I have the same problem in phpBB boards as well, but the problem does not occur when using those fancy java WYSBLAH editors.)
Ginnunga Gaming
|
|
|
Re: Cursor focus after formatting text in Firefox [message #34024 is a reply to message #33991] |
Sun, 01 October 2006 20:14 |
Ilia
Messages: 13241 Registered: January 2002
Karma: 0
|
Senior Member Administrator Core Developer |
|
|
I've tried a number of solutions and it appears that there is a browser that exists that causes it to lose the position in the textbox on large inputs. Even attempts to forcefully set the position via JavaScript are un-successful.
In IE it works fine regardless of the text quantity.
FUDforum Core Developer
|
|
|
|
Re: Cursor focus after formatting text in Firefox [message #34043 is a reply to message #34029] |
Mon, 02 October 2006 16:06 |
Ilia
Messages: 13241 Registered: January 2002
Karma: 0
|
Senior Member Administrator Core Developer |
|
|
Unfortunately there does not appear to be way. I've trying using JS to force firefox to place the cursor at the start of the selected string, but it appears to ignore this :/
FUDforum Core Developer
|
|
|
|
Re: Cursor focus after formatting text in Firefox [message #34800 is a reply to message #33954] |
Sat, 18 November 2006 10:06 |
Ernesto
Messages: 413 Registered: August 2005
Karma: 0
|
Senior Member |
|
|
Here is a fix (copy pasted from the internet):
Url for the format
<a href="javascript:void(0);" onclick="surroundText('[b]', '[/b]', document.post_form.msg_body); return false;">
function surroundText(text1, text2, textarea)
{
// Can a text range be created?
if (typeof(textarea.caretPos) != "undefined" && textarea.createTextRange)
{
var caretPos = textarea.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text1 + caretPos.text + text2 + ' ' : text1 + caretPos.text + text2;
caretPos.select();
}
// Mozilla text range wrap.
else if (typeof(textarea.selectionStart) != "undefined")
{
var begin = textarea.value.substr(0, textarea.selectionStart);
var selection = textarea.value.substr(textarea.selectionStart, textarea.selectionEnd - textarea.selectionStart);
var end = textarea.value.substr(textarea.selectionEnd);
var newCursorPos = textarea.selectionStart;
var scrollPos = textarea.scrollTop;
textarea.value = begin + text1 + selection + text2 + end;
if (textarea.setSelectionRange)
{
if (selection.length == 0)
textarea.setSelectionRange(newCursorPos + text1.length, newCursorPos + text1.length);
else
textarea.setSelectionRange(newCursorPos, newCursorPos + text1.length + selection.length + text2.length);
textarea.focus();
}
textarea.scrollTop = scrollPos;
}
// Just put them on the end, then.
else
{
textarea.value += text1 + text2;
textarea.focus(textarea.value.length - 1);
}
}
Ginnunga Gaming
|
|
|
|
|
|