• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript button.Button类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了Button类的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: test_custom_attribute_is_reported_in_dom_node

export function test_custom_attribute_is_reported_in_dom_node() {
    const btn = new Button();
    btn["test_prop"] = "test_value";
    btn.ensureDomNode();
    const domNode = btn.domNode;
    assertAttribute(domNode, "test_prop", "test_value");
}
开发者ID:sitefinitysteve,项目名称:NativeScript,代码行数:7,代码来源:dom-node-tests.ts


示例3: 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


示例4: test_property_is_reported_in_dom_node

export function test_property_is_reported_in_dom_node() {
    const btn = new Button();
    btn.text = "test_value";
    btn.ensureDomNode();
    const domNode = btn.domNode;
    assertAttribute(domNode, "text", "test_value");
}
开发者ID:sitefinitysteve,项目名称:NativeScript,代码行数:7,代码来源:dom-node-tests.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: test_falsy_property_is_reported_in_dom_node

export function test_falsy_property_is_reported_in_dom_node() {
    const btn = new Button();
    btn.text = null;
    btn.ensureDomNode();
    const domNode = btn.domNode;
    assertAttribute(domNode, "text", "null");

    btn.text = undefined;
    domNode.loadAttributes();
    assertAttribute(domNode, "text", "undefined");
}
开发者ID:sitefinitysteve,项目名称:NativeScript,代码行数:11,代码来源:dom-node-tests.ts


示例7: 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


示例8: test_custom__falsy_attribute_is_reported_in_dom_node

export function test_custom__falsy_attribute_is_reported_in_dom_node() {
    const btn = new Button();
    btn["test_prop_null"] = null;
    btn["test_prop_0"] = 0;
    btn["test_prop_undefined"] = undefined;
    btn["test_prop_empty_string"] = "";

    btn.ensureDomNode();
    const domNode = btn.domNode;
    assertAttribute(domNode, "test_prop_null", null + "");
    assertAttribute(domNode, "test_prop_0", 0 + "");
    assertAttribute(domNode, "test_prop_undefined", undefined + "");
    assertAttribute(domNode, "test_prop_empty_string", "");
}
开发者ID:sitefinitysteve,项目名称:NativeScript,代码行数:14,代码来源:dom-node-tests.ts


示例9: 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


示例10: 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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript view.Property类代码示例发布时间:2022-05-25
下一篇:
TypeScript builder.parse函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap