当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Button.on方法代码示例

本文整理汇总了TypeScript中tns-core-modules/ui/button.Button.on方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Button.on方法的具体用法?TypeScript Button.on怎么用?TypeScript Button.on使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tns-core-modules/ui/button.Button的用法示例。


在下文中一共展示了Button.on方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: createPage

export function createPage() {
    var page = new pages.Page();
    var stack = new stackModule.StackLayout();

    var btn = new button.Button();
    btn.text = "Page C new activity";
    btn.on(button.Button.tapEvent, function () {
        var nextPage = "tests/pages/navigation/pageC-new-activity";
        frame.topmost().navigate(nextPage);
    });
    stack.addChild(btn);

    var backBtn = new button.Button();
    backBtn.text = "BACK";
    backBtn.on(button.Button.tapEvent, function () {
        frame.topmost().goBack();
    });
    stack.addChild(backBtn);

    var txt = new text.TextField();
    txt.text = "text new B";
    stack.addChild(txt);

    page.content = stack;
    return page;
}
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:26,代码来源:pageB-new-activity.ts

示例2: createPage

export function createPage() {
    function createTxt(text: string) {
        var tv = new textView.TextView();
        tv.text = text;
        return tv;
    }

    var page = new pages.Page();
    var scrollView = new scroll.ScrollView();

    function performGet() {
        console.log("Getting CSS");
        http.getString("http://192.168.54.36:8080/test.css").then(
            function (r) {
                console.log("Applying CSS");
                page.css = r;
                timer.setTimeout(performGet, 1000);
            },
            function (e) {
                console.log("Error: " + e);
                timer.setTimeout(performGet, 1000);
            });
    }

    var stack = new stacks.StackLayout();
    scrollView.content = stack;

    var counter = 0;
    var btn = new btns.Button();
    btn.text = "tap";
    btn.on(btns.Button.tapEvent, function () {
        btn.text = "hi: " + counter++;
    });
    btn.isEnabled = false;

    stack.addChild(btn);
    stack.addChild(createTxt("this is label"));

    var info = new btns.Button();
    info.text = "info";
    info.className = "info";
    info.on(btns.Button.tapEvent, function () {
        info.text = "hi: " + counter++;
        btn.isEnabled = true;
    });
    stack.addChild(info);

    stack.addChild(createTxt("this is another label"));

    page.content = scrollView;
    timer.setTimeout(performGet, 2000);
    return page;
}
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:53,代码来源:page8.ts

示例3: createPage

export function createPage() {
    var page = new pages.Page();
    var stack = new stackModule.StackLayout();
    stack.style.backgroundColor = new color.Color("#FFFFFF00");

    var btn = new button.Button();
    btn.text = "Page C";
    btn.on(button.Button.tapEvent, function () {
        var nextPage = "tests/pages/navigation/pageC";
        frame.topmost().navigate(nextPage);
    });
    stack.addChild(btn);

    var btnActivity = new button.Button();
    btnActivity.text = "start activity";
    btnActivity.on(button.Button.tapEvent, function () {
        var newFrame = new frame.Frame();
        var newPage = "tests/pages/navigation/pageA-new-activity";
        newFrame.navigate(newPage);
    });
    stack.addChild(btnActivity);

    var backBtn = new button.Button();
    backBtn.text = "BACK";
    backBtn.on(button.Button.tapEvent, function () {
        frame.topmost().goBack();
    });
    stack.addChild(backBtn);

    var txt = new text.TextField();
    txt.text = "text B";
    stack.addChild(txt);

    var sv = new scroll.ScrollView();
    sv.height = 200;
    stack.addChild(sv);

    var content = new stackModule.StackLayout();
    sv.content = content;
    for (var i = 0; i < 50; i++) {
        var b = new button.Button();
        b.text = "button " + i;
        content.addChild(b);
    }

    page.content = stack;
    return page;
}
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:48,代码来源:pageB.ts

示例4: showReportPage

function showReportPage(finalMessage: string) {
    const stack = new StackLayout();
    const btn = new Button();
    btn.text = "Rerun tests";
    btn.on("tap", () => runAll(testsSelector));
    stack.addChild(btn);

    const messageContainer = new TextView();
    messageContainer.editable = messageContainer.autocorrect = false;
    messageContainer.text = finalMessage;
    stack.addChild(messageContainer);

    topmost().navigate({
        create: () => {
            const page = new Page();
            page.content = stack;
            messageContainer.focus();
            page.style.fontSize = 11;
            if (platform.isAndroid) {
                page.on('navigatedTo', () => {
                    messageContainer.focus();
                    setTimeout(() => messageContainer.dismissSoftInput());
                });
            }

            return page;
        },
        clearHistory: true
    });
}
开发者ID:slavchev,项目名称:NativeScript,代码行数:30,代码来源:testRunner.ts

示例5: createPage

export function createPage() {
    var page = new pages.Page();

    var btn = new buttons.Button();
    btn.width = 200;
    btn.height = 60;
    btn.text = "test";

    var vAligns: VerticalAlignment[] = ["stretch", "top", "middle", "bottom"];
    //var hAligns = ["stretch", "left", "center", "right"];
    var count = 0;
    btn.on(buttons.Button.tapEvent, function () {
        //page.css = "button { vertical-align:" + vAligns[(count++) % 4] + " }";
        btn.verticalAlignment = vAligns[(count++) % 4];
    })

//export function performanceTest() {
//        var testBtn = new buttons.Button();
//        var i = 0;
//        var tmp;
//        var start;
//        var end;

//        start = new Date().getTime();
//        for (i = 0; i < 1000000; i++) {
//            tmp = testBtn.verticalAlignment;
//        }
//        end = new Date().getTime();
//        console.log("GET from STYLE time: " + (end - start));

//        start = new Date().getTime();
//        for (i = 0; i < 1000000; i++) {
//            tmp = testBtn.horizontalAlignment;
//        }
//        end = new Date().getTime();
//        console.log("GET from LayoutInfo time: " + (end - start));

//        start = new Date().getTime();
//        for (i = 0; i < 1000000; i++) {
//            testBtn.verticalAlignment = vAligns[i % 4];
//        }
//        end = new Date().getTime();
//        console.log("SET to STYLE time: " + (end - start));

//        start = new Date().getTime();
//        for (i = 0; i < 1000000; i++) {
//            testBtn.horizontalAlignment = hAligns[i % 4];
//        }
//        end = new Date().getTime();
//        console.log("SET from LayoutInfo time: " + (end - start));
//    }

    page.content = btn;
    return page;
}
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:55,代码来源:page7.ts

示例6: createPage

export function createPage() {
    var page = new pageModule.Page();

    //var iconItem = new pageModule.MenuItem();
    //iconItem.text = "TEST";

    //iconItem.icon = "~/app" + "/tests" + "/test-icon.png"; // use + to stop regex replace during build
    //iconItem.on("tap", () => {
    //    console.log("Icon item tapped");
    //});
    //page.optionsMenu.addItem(iconItem);

    //var textItem = new pageModule.MenuItem();
    //textItem.text = "SAVE";
    //textItem.on("tap", () => {
    //    console.log("Save item tapped");
    //});
    //page.optionsMenu.addItem(textItem);

    var stackLayout = new stackModule.StackLayout();
    //var count = 0;
    var btn1 = new buttonModule.Button();
    btn1.text = "add item";
    //btn1.on("tap", () => {
    //    console.log("adding menu item");

    //    var newItem = new pageModule.MenuItem();
    //    var text =  "item " + count;
    //    newItem.text = text
    //    newItem.on("tap", () => {
    //        console.log("ITEM [" + text + "] tapped");
    //    });
    //    page.optionsMenu.addItem(newItem);
    //    count++;
    //});

    stackLayout.addChild(btn1);

    var btn2 = new buttonModule.Button();
    btn2.text = "navigate";
    btn2.on("tap", () => {
        var nextPage = "app/tests/pages/page16";
        frame.topmost().navigate(nextPage);
    });

    stackLayout.addChild(btn2);

    page.content = stackLayout;
    return page;
}
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:50,代码来源:page16.ts

示例7: createPage

export function createPage() {
    var page = new pages.Page();
    var grid = new gridModule.GridLayout();

    var btn = new buttons.Button();
    btn.text = "print";
    btn.on("tap", (d) => {
        print();
    });

    grid.addChild(btn);

    page.content = grid;
    return page;
}
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:15,代码来源:page5.ts

示例8: createPage

export function createPage() {

    var stack = new stackModule.StackLayout();

    var btn = new button.Button();
    btn.text = "Alert";
    btn.on(button.Button.tapEvent, function () {
        alert("Alert is global");
    });

    stack.addChild(btn);

    var page = new pages.Page();
    page.content = stack;
    return page;
}
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:16,代码来源:i73.ts

示例9: constructor

    constructor() {
        super();

        var counter: number = 0;

        var lbl = new label.Label();
        var btn = new button.Button();
        btn.text = "Tap me!";
        btn.on(button.Button.tapEvent, (args: observable.EventData) => {
            lbl.text = "Tap " + counter++;
        });

        this.addChild(lbl);
        this.addChild(btn);

        this.className = "MyStackLayout";
    }
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:17,代码来源:MyControl.ts

示例10: createPage

export function createPage() {
    var tab = new tabViewModule.TabView();
    tab.items = [];
    for (var i = 0; i < 10; i++) {

        var button = new buttonModule.Button();
        button.text = "Test";
        button.on(buttonModule.Button.tapEvent, function () {
            var topFrame = frame.topmost();
            topFrame.goBack();
        });

        let item = new tabViewModule.TabViewItem();
        item.title = "Tab " + i;
        item.view = button;
        tab.items.push(item);
    }
    var page = new pages.Page();
    page.content = tab;
    return page;
}
开发者ID:NathanWalker,项目名称:NativeScript,代码行数:21,代码来源:pageNavigation.ts


注:本文中的tns-core-modules/ui/button.Button.on方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。