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


TypeScript button.Button類代碼示例

本文整理匯總了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;未經允許,請勿轉載。