mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Now inside the <template> of a SkyElement you can use on-eventName="method" on any element to add event listeners. For example you can write <sky-button on-click="handleClick"> and then define handleClick(event) on the element class that contains the button. In adding this and tests I also realized that property bindings were not setup on the initial call to bind(), which is now fixed in this patch (See change to Node.prototype.bind). R=eseidel@google.com, rafaelw@chromium.org Review URL: https://codereview.chromium.org/812713005
62 lines
1.8 KiB
Plaintext
62 lines
1.8 KiB
Plaintext
<!--
|
|
// Copyright 2014 The Chromium Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
-->
|
|
<sky>
|
|
<import src="/sky/framework/sky-element/sky-element.sky" as="SkyElement"/>
|
|
<import src="/sky/framework/sky-button/sky-button.sky"/>
|
|
<import src="/sky/framework/sky-box/sky-box.sky"/>
|
|
<import src="/sky/framework/sky-checkbox/sky-checkbox.sky"/>
|
|
<import src="/sky/framework/sky-radio/sky-radio.sky"/>
|
|
<sky-element name="widget-root">
|
|
<template>
|
|
<style>
|
|
div { display: paragraph; }
|
|
</style>
|
|
|
|
<sky-box title='Buttons'>
|
|
<sky-button id='button' on-click='handleClick'>Button</sky-button>
|
|
<div>highlight: {{ myButton.highlight }}</div>
|
|
<div>clickCount: {{ clickCount }}</div>
|
|
</sky-box>
|
|
|
|
<sky-box title='Checkboxes'>
|
|
<div><sky-checkbox id='checkbox' />Checkbox</div>
|
|
<div>highlight: {{ myCheckbox.highlight }}</div>
|
|
<div>checked: {{ myCheckbox.checked }}</div>
|
|
|
|
<div><sky-checkbox id='checkbox' checked='true'/>Checkbox, default checked.</div>
|
|
</sky-box>
|
|
|
|
<sky-box title='Radios'>
|
|
<sky-box title='Group One'>
|
|
<div><sky-radio group='foo'/>one</div>
|
|
<div><sky-radio group='foo' selected='true' />two</div>
|
|
<div><sky-radio group='foo'/>three</div>
|
|
</sky-box>
|
|
<sky-box title='Group Two'>
|
|
<div><sky-radio group='bar'/>A</div>
|
|
<div><sky-radio group='bar'/>B</div>
|
|
<div><sky-radio group='bar' selected='true' />C</div>
|
|
</sky-box>
|
|
</sky-box>
|
|
|
|
</template>
|
|
<script>
|
|
module.exports = class extends SkyElement {
|
|
attached() {
|
|
this.myButton = this.shadowRoot.getElementById('button');
|
|
this.myCheckbox = this.shadowRoot.getElementById('checkbox');
|
|
this.clickCount = 0;
|
|
}
|
|
handleClick(event) {
|
|
this.clickCount++;
|
|
}
|
|
}.register();
|
|
</script>
|
|
</sky-element>
|
|
|
|
<widget-root />
|
|
</sky>
|