MSGestureHold is ignored by WebBrowser Control for Windows Phone 8.1

北战南征 提交于 2019-12-02 06:53:03

问题


I am updating my browser app to support Windows Phone 8.1 and I noticed the MSGestureHoldevent is not raised.

To reproduce this error,

  1. Download the MS Mini-browser Sample.
  2. Upgrade the project to WP8.1 project in Visual Studio 2013 and add IsScriptEnabled="True".
  3. Run the project on WP8.1 emulator or device
  4. Navigate to this touch and mouse example.
  5. Scroll down to the Sample 1: handling the hold gesture section and click the IE11 users test.

Notice that MSGestureHold is not working.

However the project is working when tested in

  1. Default Windows Phone Internet Explorer app for WP8 and WP8.1
  2. WebBrowser control in WP8 app.

Is this a bug?


回答1:


I guess this is the WebBrowser control's bug.

I test several gesture events with WebBrowser control for WP8.1, such as pointerdown,MSGestureHold,MSGestureChange,and MSGestureTap. Finally, pointerdown, MSGestureChange and MSGestureTap can be triggered normally,except MSGestureHold. So I guess this is a bug.




回答2:


This code works fine in webview for WPhone 8.1 apps :

var init = function(){
    var myState = // context
    var target = // DOM variable target
    var msg = new MSGesture();

    msg.target = target;

    target.addEventListener("MSGestureHold", function (evt) { buttonTactileListener.apply(myState, [evt, msg]); }, false);
    target.addEventListener("pointerdown", function (evt) { buttonTactileListener.apply(myState, [evt, msg]); }, false);
    target.addEventListener("MSGestureEnd", function (evt) { buttonTactileListener.apply(myState, [evt, msg]); }, false);
}
var buttonTactileListener = function (evt, msgesture) {
    var myState = this;
    if (evt.type == "pointerdown") {
        msgesture.addPointer(evt.pointerId);
        return;
    }
    if (evt.type == "MSGestureHold") {
        ///do something
        return;
    }

    if (evt.type == "MSGestureEnd") {
        // renew instance of handler
        msgesture = new MSGesture();
        msgesture.target = evt.target;
        return;
    }
}


来源:https://stackoverflow.com/questions/23209243/msgesturehold-is-ignored-by-webbrowser-control-for-windows-phone-8-1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!