PDA

View Full Version : [CLOSED] Have a HTML Editor in window, want to give focus and put cursor at end of content...



rthiney
Mar 28, 2014, 6:42 PM
.focus() doesn't seem to work.

Is there any solid work around? I tried just about everything I found here in forum...

I just want the cursor to be at the end of the content, ready for user to type...

Thanks

geoffrey.mcgill
Mar 28, 2014, 10:03 PM
Ya, for some reason calling .focus() does not appear to work. We will have to try and fix.

Thanks for the report.

Daniil
Mar 28, 2014, 11:24 PM
Hi everybody,

It appears to be working in this scenario. Tested on FireFox.

Example

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html>
<html>
<head runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:Window ID="Window1" runat="server" Hidden="true" DefaultFocus="HtmlEditor1">
<Items>
<ext:HtmlEditor ID="HtmlEditor1" runat="server" />
</Items>
</ext:Window>

<ext:Button runat="server" Text="Show" Handler="App.Window1.show();" />
</form>
</body>
</html>

geoffrey.mcgill
Mar 28, 2014, 11:34 PM
It appears to be working in this scenario. Tested on FireFox.

Try and just call .focus() on the HtmlEditor.


App.HtmlEditor1.focus();

Daniil
Mar 28, 2014, 11:45 PM
From a JavaScript console of a browser? Yes, it appears to be not working if call from FireBug. Maybe, FireBug takes focus back. I am not sure.

It appears to work in this example.

Example

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html>
<html>
<head runat="server">
<title>Ext.NET v2 Example</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />

<ext:HtmlEditor ID="HtmlEditor1" runat="server" />

<ext:TextField ID="TextField1" runat="server" />

<ext:Button runat="server" Text="Focus HtmlEditor" Handler="App.HtmlEditor1.focus();" />

<ext:Button runat="server" Text="Focus TextField" Handler="App.TextField1.focus();" />
</form>
</body>
</html>

geoffrey.mcgill
Mar 29, 2014, 2:03 AM
Maybe, FireBug takes focus back. I am not sure.

Yes, that does appear to be the case.

Now, place cursor at the end.

Daniil
Mar 29, 2014, 5:39 AM
Now, place cursor at the end.

Do you mean that the cursor is not placed at the end in my example?