OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 import '../fn2.dart'; | 5 import '../fn2.dart'; |
6 | 6 |
7 abstract class ButtonBase extends Component { | 7 abstract class ButtonBase extends Component { |
8 | 8 |
9 ButtonBase({ Object key }) : super(key: key); | 9 ButtonBase({ Object key, this.highlight: false }) : super(key: key); |
10 | 10 |
11 UINode buildContent(); | 11 bool highlight; |
12 | 12 |
13 UINode build() { | 13 void syncFields(ButtonBase source) { |
14 return new EventListenerNode( | 14 highlight = source.highlight; |
15 buildContent(), | |
16 onPointerDown: _handlePointerDown, | |
17 onPointerUp: _handlePointerUp, | |
18 onPointerCancel: _handlePointerCancel | |
19 ); | |
20 } | 15 } |
21 | 16 |
22 bool highlight = false; | |
23 | |
24 void _handlePointerDown(_) { | 17 void _handlePointerDown(_) { |
25 setState(() { | 18 setState(() { |
26 highlight = true; | 19 highlight = true; |
27 }); | 20 }); |
28 } | 21 } |
29 void _handlePointerUp(_) { | 22 void _handlePointerUp(_) { |
30 setState(() { | 23 setState(() { |
31 highlight = false; | 24 highlight = false; |
32 }); | 25 }); |
33 } | 26 } |
34 void _handlePointerCancel(_) { | 27 void _handlePointerCancel(_) { |
35 setState(() { | 28 setState(() { |
36 highlight = false; | 29 highlight = false; |
37 }); | 30 }); |
38 } | 31 } |
| 32 |
| 33 UINode build() { |
| 34 return new EventListenerNode( |
| 35 buildContent(), |
| 36 onPointerDown: _handlePointerDown, |
| 37 onPointerUp: _handlePointerUp, |
| 38 onPointerCancel: _handlePointerCancel |
| 39 ); |
| 40 } |
| 41 |
| 42 UINode buildContent(); |
| 43 |
39 } | 44 } |
OLD | NEW |