當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript Label.getGestureObservers方法代碼示例

本文整理匯總了TypeScript中tns-core-modules/ui/label.Label.getGestureObservers方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Label.getGestureObservers方法的具體用法?TypeScript Label.getGestureObservers怎麽用?TypeScript Label.getGestureObservers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tns-core-modules/ui/label.Label的用法示例。


在下文中一共展示了Label.getGestureObservers方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: createPage

export function createPage() {

    var stack = new stackLayoutModule.StackLayout();
    var labelHeight = Math.round(deviceProperties.screen.mainScreen.heightPixels / (7 * deviceProperties.screen.mainScreen.scale));
    var stopButton = new button.Button();
    stopButton.text = "Stop Detecting Gestures";
    stack.addChild(stopButton);

    var tapLabel = new labelModule.Label();
    tapLabel.text = "Tap here";
    stack.addChild(tapLabel);

    var doubletapLabel = new labelModule.Label();
    doubletapLabel.text = "Double Tap here";
    stack.addChild(doubletapLabel);

    var longpressLabel = new labelModule.Label();
    longpressLabel.text = "Long Press here";
    stack.addChild(longpressLabel);

    var swipeLabel = new labelModule.Label();
    swipeLabel.height = labelHeight;
    swipeLabel.text = "Swipe here";
    swipeLabel.textWrap = true;
    stack.addChild(swipeLabel);

    var panLabel = new labelModule.Label();
    panLabel.height = labelHeight;
    panLabel.text = "Pan here";
    panLabel.textWrap = true;
    stack.addChild(panLabel);

    var pinchLabel = new labelModule.Label();
    pinchLabel.height = labelHeight;
    pinchLabel.text = "Pinch here";
    pinchLabel.textWrap = true;
    stack.addChild(pinchLabel);

    var rotaionLabel = new labelModule.Label();
    rotaionLabel.height = labelHeight;
    rotaionLabel.text = "Rotate here";
    rotaionLabel.textWrap = true;
    stack.addChild(rotaionLabel);

    stopButton.on(button.Button.tapEvent, function () {
        observer1.disconnect();
        observer2.disconnect();
        observer3.disconnect();
        observer4.disconnect();
        observer5.disconnect();
        observer6.disconnect();
        observer7.disconnect();
        tapLabel.text = "Gestures detection disabled";
        doubletapLabel.text = "Gestures detection disabled";
        longpressLabel.text = "Gestures detection disabled";
        swipeLabel.text = "Gesturesd detection disabled";
        panLabel.text = "Gestures detection disabled";
        pinchLabel.text = "Gestures detection disabled";
        rotaionLabel.text = "Gestures detection disabled";
    });

    tapLabel.on(gestures.GestureTypes.tap, function (args: gestures.GestureEventData) {
        tapLabel.text = "Tap gesture detected, " + (args.object === tapLabel);
    });

    var observer1 = tapLabel.getGestureObservers(gestures.GestureTypes.tap)[0];

    doubletapLabel.on(gestures.GestureTypes.doubleTap, function (args: gestures.GestureEventData) {
        doubletapLabel.text = "Double Tap gesture detected, " + (args.object === doubletapLabel);
    });

    var observer2 = doubletapLabel.getGestureObservers(gestures.GestureTypes.doubleTap)[0];

    longpressLabel.on(gestures.GestureTypes.longPress, function (args: gestures.GestureEventData) {
        longpressLabel.text = "Long Press gesture detected, " + (args.object === longpressLabel);
    });

    var observer3 = longpressLabel.getGestureObservers(gestures.GestureTypes.longPress)[0];

    swipeLabel.on(gestures.GestureTypes.swipe, function (args: gestures.SwipeGestureEventData) {
        swipeLabel.text = "Swipe Direction: " + args.direction + ", " + (args.object === swipeLabel);// + getStateAsString(args.state);
    });

    var observer4 = swipeLabel.getGestureObservers(gestures.GestureTypes.swipe)[0];

    panLabel.on(gestures.GestureTypes.pan, function (args: gestures.PanGestureEventData) {
        panLabel.text = "Pan deltaX:" + Math.round(args.deltaX) + "; deltaY:" + Math.round(args.deltaY) + ";" + ", " + (args.object === panLabel) + getStateAsString(args.state);
    });

    var observer5 = panLabel.getGestureObservers(gestures.GestureTypes.pan)[0];

    pinchLabel.on(gestures.GestureTypes.pinch, function (args: gestures.PinchGestureEventData) {
        pinchLabel.text = "Pinch Scale: " + Math.round(args.scale) + ", " + (args.object === pinchLabel) + getStateAsString(args.state);
    });

    var observer6 = pinchLabel.getGestureObservers(gestures.GestureTypes.pinch)[0];

    rotaionLabel.on(gestures.GestureTypes.rotation, function (args: gestures.RotationGestureEventData) {
        rotaionLabel.text = "Rotation: " + Math.round(args.rotation) + ", " + (args.object === rotaionLabel) + getStateAsString(args.state);
    });
//.........這裏部分代碼省略.........
開發者ID:sitefinitysteve,項目名稱:NativeScript,代碼行數:101,代碼來源:gestures.ts


注:本文中的tns-core-modules/ui/label.Label.getGestureObservers方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。