Stop all Events (preventDefault) an Ext Window when Show window.setVisible(true)

Page 1 of 2 12 LastLast
  1. #1

    Stop all Events (preventDefault) an Ext Window when Show window.setVisible(true)

    This problem is related to this subject:
    http://forums.ext.net/showthread.php...ountdown-alert

    I have a Window that is Hidden. In a moment I change the visibility using

    frmTimeOut.setVisible(true);
    But when Show the window.. then it launch an event and is detected by the browser (probed wit IE, FF, GC) as "mouseover".
    I'm trying to prevent this event adding this to Window:

        <Listeners>
            <Show PreventDefault="true" />
        </Listeners>
    Or with this:

    <Listeners>
            <Show StopPropagation="true" />
        </Listeners>
    But the browser steel detecting as "mouseover" event.

    How can I use .stopPropagation ( ); or preventDefault(); when the window is showing?
  2. #2
    I found this code, but I don't understand very good.

    Ext.lib.Event.preventDefault();
    I can use it in any part of code?
  3. #3
    Hi @equiman,

    Please provide a sample to test.
  4. #4
    Sample is related to this forum: http://forums.ext.net/showthread.php...5884#post95884

    I make work, I'm using 2 secs idle time to fix it.

    stopCount = function () {
            if (vis === true) {
                //2 seconds Idle (no detect events, because showing alert window is detected as mousemove)
                if ((min - sec) < 58) {
                    vis = false;
                }
            }
            else {
                // Convert minutes to second, minus 10 to be sure Client TimeOut occurs first than Server Timeout
                min = (document.getElementById('txtMinTimeOut').value * 60) - 10;
                sec = 0;
                clearTimeout(timer);
                doTimer();
            }
    But I want to fix it with a real solution. The problem is... when I launch the countdown window is detected as mousemove then the countdown is started again.

    I think ... the posible solution is launch (set visible) the window and immediately stop event related to this launch. I was tried with:

    <Listeners>
        <Show PreventDefault="true" />
    </Listeners>
    And with:

    <Listeners>
            <Show StopPropagation="true" />
        </Listeners>
    But the browser steel detecting as "mouseover" event.
  5. #5
    Unfortunately, I can't say anything concrete.

    Could you provide something which we could copy, paste, run and reproduce the issue?
  6. #6
    OK... I'm working on It. I think tomorrow can I publish the example.

    Thanks!
  7. #7
    I do the example... but now the Window don`t send any mouse event ... all works correctly :S

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="pageone.aspx.cs" Inherits="Inaltec.SRT.Sitio.pageone" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html>
    
    <html>
    <head id="Head1" runat="server">
        <title>Page One</title>
    
        <script runat="server">
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack && !X.IsAjaxRequest)
                {
                    // Definir el Theme por Defecto
                    Session["Ext.Net.Theme"] = Ext.Net.Theme.Default;
                    MainResourceManager.SetTheme(Ext.Net.Theme.Default);
                }
            }
        </script>
    
        <script type="text/javascript">
            var sec = 0;
    
            doTimer = function () {
                sec++;
                timer = setTimeout('doTimer()', 1000);
                updateCount();
                if (sec > 5) {
                    if (VentanaTimeOut.hidden) {
                        VentanaTimeOut.setVisible(true);
                    }
                }
            };
    
            // Evento cuando se mueve el Mouse
            document.onmousemove = function () {
                stopCount("mouse");
                //return false;
            };
            // Evento cuando se presiona alguna tecla
            document.onkeypress = function () {
                stopCount("key");
                //return false;
            };
    
            stopCount = function (event) {
                alert("Detected: " + event)
            };
    
            updateCount = function () {
                var mensaje = 'Counter';
                var tiempo = sec;
                var unidad = 'seconds';
    
                Ext.getCmp('lblText').setText(mensaje + ' ' + tiempo + ' ' + unidad);
            }
        </script>
    </head>
    <body>
        <form id="Form1" runat="server">
            <asp:ScriptManager ID="smSrtInaltec" EnableScriptLocalization="true" runat="server" />
            <ext:ResourceManager ID="MainResourceManager" runat="server">
                <Listeners>
                    <DocumentReady Handler="doTimer();" />
                </Listeners>
            </ext:ResourceManager>
    
            <ext:Window 
                ID="VentanaTimeOut" runat="server" Width="235" Height="50" Modal="false" Resizable="False"
                Hidden="true" Closable="false" Layout="FormLayout" Draggable="false" Padding="12" Cls="FondoBlanco">
                <Items>
                    <ext:Label ID="lblText" runat="server" HideLabel="true" Text="Counter 0 sec" AutoWidth="true" />
                </Items>
            </ext:Window>
        </form>
    </body>
    </html>
    This exercise is good, because I know that the problem isn't the widow.show() but now... I follow my search.

    Thanks @daniil!!!

    While I found how or what is generating the event... Ext have any kind of stop or prevent all events in a moment?
  8. #8
    Quote Originally Posted by equiman View Post
    Ext have any kind of stop or prevent all events in a moment?
    Please look at the Ext.EventManager class.
    http://docs.sencha.com/ext-js/4-1/#!...preventDefault
    http://docs.sencha.com/ext-js/4-1/#!...thod-stopEvent
    http://docs.sencha.com/ext-js/4-1/#!...topPropagation
  9. #9
    Thanks @daniil i'm work with Ext.EventManager
  10. #10
    Finally I found the problem... it's because when I show the Windows take the focus, and the other control lose the focus... then launch an event.

    Soluction is, add the property FocusOnToFront="false" to this Windows.

    <ext:Window 
    ID="wndTimeOut" 
        runat="server" 
        Width="235" 
        Height="70" 
        Modal="false"
        Resizable="False"
        Hidden="true"
        Closable="false"
        Layout="FormLayout"
        Draggable="false"
        Padding="5"
        FocusOnToFront="false">
    Hope it can help others!
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 3
    Last Post: Mar 19, 2012, 12:35 PM
  2. Replies: 1
    Last Post: Jan 27, 2012, 11:32 AM
  3. [CLOSED] Window toFront: true
    By CarWise in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Jan 20, 2011, 8:56 AM
  4. Replies: 4
    Last Post: Sep 17, 2010, 10:33 PM
  5. [CLOSED] Desktop Window | Show Handler | Stop Event
    By amitpareek in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Jul 20, 2010, 10:32 PM

Tags for this Thread

Posting Permissions