Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(68)

Side by Side Diff: sky/sdk/lib/editing/editable_text.dart

Issue 1194113002: EditableText underlines the word being edited (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: do not constrain the input components width Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | sky/sdk/lib/editing/input.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 'dart:async'; 5 import 'dart:async';
6 6
7 import '../painting/text_style.dart';
7 import '../widgets/basic.dart'; 8 import '../widgets/basic.dart';
8 import 'editable_string.dart'; 9 import 'editable_string.dart';
9 10
10 class EditableText extends Component { 11 class EditableText extends Component {
11 12
12 EditableText({String key, this.value, this.focused}) 13 EditableText({String key, this.value, this.focused})
13 : super(key: key, stateful: true); 14 : super(key: key, stateful: true);
14 15
15 // static final Style _cursorStyle = new Style(''' 16 // static final Style _cursorStyle = new Style('''
16 // width: 2px; 17 // width: 2px;
17 // height: 1.2em; 18 // height: 1.2em;
18 // vertical-align: top; 19 // vertical-align: top;
19 // background-color: ${Blue[500]};''' 20 // background-color: ${Blue[500]};'''
20 // ); 21 // );
21 22
22 // static final Style _composingStyle = new Style('''
23 // text-decoration: underline;'''
24 // );
25
26 EditableString value; 23 EditableString value;
27 bool focused; 24 bool focused;
28 25
29 void syncFields(EditableText source) { 26 void syncFields(EditableText source) {
30 value = source.value; 27 value = source.value;
31 focused = source.focused; 28 focused = source.focused;
32 } 29 }
33 30
34 Timer _cursorTimer; 31 Timer _cursorTimer;
35 bool _showCursor = false; 32 bool _showCursor = false;
(...skipping 21 matching lines...) Expand all
57 _cursorTimer = null; 54 _cursorTimer = null;
58 _showCursor = false; 55 _showCursor = false;
59 } 56 }
60 57
61 Widget build() { 58 Widget build() {
62 if (focused && _cursorTimer == null) 59 if (focused && _cursorTimer == null)
63 _startCursorTimer(); 60 _startCursorTimer();
64 else if (!focused && _cursorTimer != null) 61 else if (!focused && _cursorTimer != null)
65 _stopCursorTimer(); 62 _stopCursorTimer();
66 63
67 //List<Widget> children = new List<Widget>();
68 String hack = "";
69
70 if (!value.composing.isValid) { 64 if (!value.composing.isValid) {
71 // children.add(new TextFragment(value.text)); 65 return new Text(value.text);
72 hack += value.text;
73 } else {
74 hack += value.textBefore(value.composing);
75 hack += value.textInside(value.composing);
76 hack += value.textAfter(value.composing);
77 // if (!composing.isEmpty) {
78 // children.add(new TextFragment(
79 // composing,
80 // key: 'composing',
81 // style: _composingStyle
82 // ));
83 // }
84
85 // String afterComposing = value.textAfter(value.composing);
86 // if (!afterComposing.isEmpty)
87 // children.add(new TextFragment(afterComposing));
88 } 66 }
89 67
90 // if (_showCursor) 68 return new StyledText(elements: [
91 // children.add(new Container( 69 const TextStyle(),
92 // key: 'cursor', 70 value.textBefore(value.composing),
93 // // style: _cursorStyle 71 [const TextStyle(decoration: underline), value.textInside(value.composing) ],
94 // )); 72 value.textAfter(value.composing)
95 73 ]);
96 return new Text(hack);
97 } 74 }
98 } 75 }
OLDNEW
« no previous file with comments | « no previous file | sky/sdk/lib/editing/input.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698