Windows 8.1中未触发MSGestureHold事件

时间:2014-10-17 12:04:35

标签: windows-phone-8

我的应用使用Silverlight 8.0 SDK,MSGestureHold事件适用于Windows 8,但如果在8.1上测试相同,则不会触发事件。

1 个答案:

答案 0 :(得分:0)

此代码适用于WPhone 8.1应用的webview:

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;
    }
}