FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum Development » Bug Reports » Cursor focus after formatting text in Firefox
Show: Today's Messages :: Unread Messages :: Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
Message by Ernesto is ignored  [reveal message]  [reveal all messages by Ernesto]  [stop ignoring this user] Go to next message
Re: Cursor focus after formatting text in Firefox [message #33962 is a reply to message #33954] Fri, 29 September 2006 10:22 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
remove from buddy list
ignore all messages by this user
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
Message by Ernesto is ignored  [reveal message]  [reveal all messages by Ernesto]  [stop ignoring this user] Go to previous messageGo to next message
Re: Cursor focus after formatting text in Firefox [message #34024 is a reply to message #33991] Sun, 01 October 2006 16:14 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
remove from buddy list
ignore all messages by this user
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
Message by Ernesto is ignored  [reveal message]  [reveal all messages by Ernesto]  [stop ignoring this user] Go to previous messageGo to next message
Re: Cursor focus after formatting text in Firefox [message #34043 is a reply to message #34029] Mon, 02 October 2006 12:06 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
remove from buddy list
ignore all messages by this user
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
Message by Ernesto is ignored  [reveal message]  [reveal all messages by Ernesto]  [stop ignoring this user] Go to previous messageGo to next message
Re: Cursor focus after formatting text in Firefox [message #34800 is a reply to message #33954] Sat, 18 November 2006 05:06 Go to previous messageGo to next message
Ernesto is currently offline  Ernesto   Sweden
Messages: 413
Registered: August 2005
Karma: 0
Senior Member
remove from buddy list
stop ignoring messages by this user
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);
	}
}




Re: Cursor focus after formatting text in Firefox [message #34825 is a reply to message #34800] Sun, 19 November 2006 12:17 Go to previous messageGo to next message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
remove from buddy list
ignore all messages by this user
Thanks for that info. I've reviewed the code and applied the relevant focus bit to the FUDforum's code.

FUDforum Core Developer
Re: Cursor focus after formatting text in Firefox [message #34860 is a reply to message #33954] Mon, 20 November 2006 19:20 Go to previous messageGo to next message
Ernesto is currently offline  Ernesto   Sweden
Messages: 413
Registered: August 2005
Karma: 0
Senior Member
remove from buddy list
stop ignoring messages by this user
The lib.js you currently have in the CVS does not help the problem I am afraid Ilia. I am not good with JavaScript so I dont even understand the code, all I know is the code I posted works, while the new lib.js does not Sad

Re: Cursor focus after formatting text in Firefox [message #34869 is a reply to message #34860] Tue, 21 November 2006 10:14 Go to previous message
Ilia is currently offline  Ilia   Canada
Messages: 13241
Registered: January 2002
Karma: 0
Senior Member
Administrator
Core Developer
remove from buddy list
ignore all messages by this user
I've tested it n Firefox 2.0 and it works properly in that browser.

FUDforum Core Developer
Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
Previous Topic: SOLVED: &amp; and stuff in last message
Next Topic: Freaking out: My theme vanished
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Oct 04 19:47:26 EDT 2022

Total time taken to generate the page: 0.00508 seconds