GitHub user sgrebnov opened a pull request:

    https://github.com/apache/incubator-cordova-wp7/pull/3

    Minor improvement for CB-953 mouse events fired twice

    Reviewed Jesse’s implementation – looks great. But there is a case 
where we still get click event fired twice – explained below with the fix. 
    
    For situations where we have only little mouse move IE still generates own 
mouse events – pls take a look on this demo video 
http://dl.dropbox.com/u/23085338/CordovaDoubleClickSample.avi . So we both 
generates the events. The workaround is to add the following. This means that 
if we already handled mouse move then prevent IE to generate own events.
            void Border_Tap(object sender, GestureEventArgs e)
            {
                // prevents generating duplicated mouse events
                // firstMouseMove == FALSE means we already handled this 
situation and generated mouse events
                e.Handled = ! this.firstMouseMove;
            }
    
    But I found out that when you press something your clicks are not ideal so 
in many cases there is still move event fired with 1-5px  delta.  In such cases 
we generate our own events and prevents native so sometimes we encounter with 
our previous problem when text field is not focused. The workaround for this 
problem is to add small delta threshold to consider move as a real move. This 
guaranties that for some “not ideal” user touches which have some delta (so 
generate move event) we still use browser generated native events instead of 
our custom.  It seems to work very well.
    
                if (firstMouseMove)
                {
                    // even for simple tap there are situations where ui 
control generates move with some little delta value
                    // we should avoid such situations allowing to browser 
control generate native js mousedown/up/click events
                    if (Math.Abs(pos.X - mouseDownPos.X) + Math.Abs(pos.Y - 
mouseDownPos.Y) <= MouseMoveDeltaThreshold)
                    {
                        return;
                    }
    
    Final version in action  
http://dl.dropbox.com/u/23085338/CordovaDoubleClickSample2.avi 


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/sgrebnov/incubator-cordova-wp7 master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-cordova-wp7/pull/3.patch

----
commit f8d313d09f84b373198b83abc5b930b88516ad36
Author: Sergei Grebnov <[email protected]>
Date:   2012-06-28T07:07:00-07:00

    Minor improvement for CB-953 mouse events fired twice

----

Reply via email to