[CLOSED] HtmlEditor KeyPress listener?

  1. #1

    [CLOSED] HtmlEditor KeyPress listener?

    Hi,

    What's the equivalent of the KeyPress listener for HtmlEditor? I'd like to be able to catch the text change event on this control so any other workaround would be welcome.

    Thanks,

    Vadym
    Last edited by Daniil; Jun 04, 2012 at 5:34 PM. Reason: [CLOSED]
  2. #2
    Hi,

    Here is the example based on
    http://forums.ext.net/showthread.php?3417

    Example
    <%@ Page Language="C#" %>
     
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.NET Example</title>
    
        <script type="text/javascript">
            var catchKey = function (ed, fn) {
                if (Ext.isGecko) {
                    Ext.EventManager.on(ed.getDoc(), 'keypress', fn, ed);
                } else if (Ext.isIE || Ext.isSafari || Ext.isOpera) {
                    Ext.EventManager.on(ed.getDoc(), 'keydown', fn, ed);
                }
            };
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:HtmlEditor ID="HtmlEditor1" runat="server">
                <Listeners>
                    <Initialize Handler="catchKey(this, function (e) {
                                             console.log(e.getKey());
                                         });" />
                </Listeners>
            </ext:HtmlEditor>
        </form>
    </body>
    </html>
  3. #3
    Thanks Daniil! That workaround was helpful.

    Vadym
  4. #4
    Hi,
    I'm trying to make this example work on the latest version of Ext.Net (Ext.NET 3.0.0 (Includes Ext JS 5.0.1 commercial)) and i'm not having any luck with that.
    Can anyone help me please?

    PS.: Should i make this post on the "3.x Help" forum and reference this thread?

    Thanks in advance,
  5. #5
    Hi @Tanielian,

    PS.: Should i make this post on the "3.x Help" forum and reference this thread?
    Personally, I prefer if a new forum is started with cross-references to a related thread of another Ext.NET version. Though, it works both ways.

    There is an issue in ExtJS 5.0. Its event handler attachment API cannot attach an event handler to an iframe. So, Ext.EventManager.on doesn't work with ed.getDoc().

    You can attach an event handler using the standard DOM API.

    <%@ Page Language="C#" %>
    
    <!DOCTYPE html>
    
    <html>
    <head runat="server">
        <title>Ext.NET v3 Example</title>
    
        <script>
            var onInitialize = function (htmlEditor) {
                htmlEditor.getDoc()[Ext.isGecko ? 'onkeypress' : 'onkeydown'] = function (e) {
                    var extEvent = new Ext.event.Event(e);
    
                    console.log(extEvent.getKey());
                };
            };
        </script>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:HtmlEditor runat="server">
                <Listeners>
                    <Initialize Fn="onInitialize" />
                </Listeners>
            </ext:HtmlEditor>
        </form>
    </body>
    </html>
  6. #6
    Thanks a lot.
  7. #7
    Here is a related Ext.NET v3 thread.
    http://forums.ext.net/showthread.php?60078

Similar Threads

  1. Replies: 4
    Last Post: Oct 01, 2012, 9:58 AM
  2. [CLOSED] ListView with HtmlEditor -> HtmlEditor value is null
    By SouthDeveloper in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Apr 17, 2012, 12:50 AM
  3. Replies: 7
    Last Post: Jun 15, 2011, 7:34 PM
  4. Replies: 1
    Last Post: Nov 11, 2010, 8:15 PM
  5. How to capture ENTER keypress in HTMLEditor?
    By mahyar in forum 1.x Help
    Replies: 0
    Last Post: Mar 30, 2010, 7:56 AM

Tags for this Thread

Posting Permissions