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 '../fn.dart'; | 5 import '../fn.dart'; |
6 import 'material.dart'; | |
7 | 6 |
8 abstract class ButtonBase extends Material { | 7 abstract class ButtonBase extends Component { |
9 bool highlight = false; | 8 bool highlight = false; |
10 | 9 |
11 ButtonBase({ Object key }) : super(key: key) { | 10 ButtonBase({ Object key }) : super(key: key) { |
12 events.listen('pointerdown', _handlePointerDown); | 11 events.listen('pointerdown', _handlePointerDown); |
13 events.listen('pointerup', _handlePointerUp); | 12 events.listen('pointerup', _handlePointerUp); |
14 events.listen('pointercancel', _handlePointerCancel); | 13 events.listen('pointercancel', _handlePointerCancel); |
15 } | 14 } |
16 | 15 |
17 void _handlePointerDown(_) { | 16 void _handlePointerDown(_) { |
18 setState(() { | 17 setState(() { |
19 highlight = true; | 18 highlight = true; |
20 }); | 19 }); |
21 } | 20 } |
22 void _handlePointerUp(_) { | 21 void _handlePointerUp(_) { |
23 setState(() { | 22 setState(() { |
24 highlight = false; | 23 highlight = false; |
25 }); | 24 }); |
26 } | 25 } |
27 void _handlePointerCancel(_) { | 26 void _handlePointerCancel(_) { |
28 setState(() { | 27 setState(() { |
29 highlight = false; | 28 highlight = false; |
30 }); | 29 }); |
31 } | 30 } |
32 } | 31 } |
OLD | NEW |