OLD | NEW |
1 part of widgets; | 1 part of widgets; |
2 | 2 |
3 class Button extends ButtonBase { | 3 class Button extends ButtonBase { |
4 | 4 |
5 static Style _style = new Style(''' | 5 static Style _style = new Style(''' |
| 6 transform: translateX(0); |
6 display: inline-flex; | 7 display: inline-flex; |
7 border-radius: 4px; | 8 border-radius: 4px; |
8 justify-content: center; | 9 justify-content: center; |
9 align-items: center; | 10 align-items: center; |
10 border: 1px solid blue; | 11 border: 1px solid blue; |
11 -webkit-user-select: none; | 12 -webkit-user-select: none; |
12 margin: 5px;''' | 13 margin: 5px;''' |
13 ); | 14 ); |
14 | 15 |
15 static Style _highlightStyle = new Style(''' | 16 static Style _highlightStyle = new Style(''' |
| 17 transform: translateX(0); |
16 display: inline-flex; | 18 display: inline-flex; |
17 border-radius: 4px; | 19 border-radius: 4px; |
18 justify-content: center; | 20 justify-content: center; |
19 align-items: center; | 21 align-items: center; |
20 border: 1px solid blue; | 22 border: 1px solid blue; |
21 -webkit-user-select: none; | 23 -webkit-user-select: none; |
22 margin: 5px; | 24 margin: 5px; |
23 background-color: orange;''' | 25 background-color: orange;''' |
24 ); | 26 ); |
25 | 27 |
26 Node content; | 28 Node content; |
27 sky.EventListener onClick; | 29 sky.EventListener onClick; |
28 | 30 |
29 Button({ Object key, this.content, this.onClick }) : super(key: key); | 31 Button({ Object key, this.content, this.onClick }) : super(key: key); |
30 | 32 |
31 Node render() { | 33 Node render() { |
32 return new Container( | 34 return new Container( |
33 key: 'Button', | 35 key: 'Button', |
34 style: _highlight ? _highlightStyle : _style, | 36 style: _highlight ? _highlightStyle : _style, |
35 onClick: onClick, | 37 onClick: onClick, |
36 onPointerDown: _handlePointerDown, | 38 onPointerDown: _handlePointerDown, |
37 onPointerUp: _handlePointerUp, | 39 onPointerUp: _handlePointerUp, |
38 onPointerCancel: _handlePointerCancel, | 40 onPointerCancel: _handlePointerCancel, |
39 children: [content] | 41 children: [super.render(), content] |
40 ); | 42 ); |
41 } | 43 } |
42 } | 44 } |
OLD | NEW |