OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "ui/views/controls/textfield/native_textfield_views.h" | 5 #include "ui/views/controls/textfield/native_textfield_views.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 // TODO: Remove once NativeTextfield implementations are consolidated to | 136 // TODO: Remove once NativeTextfield implementations are consolidated to |
137 // Textfield. | 137 // Textfield. |
138 textfield_->OnMouseReleased(event); | 138 textfield_->OnMouseReleased(event); |
139 // Cancel suspected drag initiations, the user was clicking in the selection. | 139 // Cancel suspected drag initiations, the user was clicking in the selection. |
140 if (initiating_drag_ && MoveCursorTo(event.location(), false)) | 140 if (initiating_drag_ && MoveCursorTo(event.location(), false)) |
141 SchedulePaint(); | 141 SchedulePaint(); |
142 initiating_drag_ = false; | 142 initiating_drag_ = false; |
143 OnAfterUserAction(); | 143 OnAfterUserAction(); |
144 } | 144 } |
145 | 145 |
146 ui::EventResult NativeTextfieldViews::OnGestureEvent(ui::GestureEvent* event) { | 146 void NativeTextfieldViews::OnGestureEvent(ui::GestureEvent* event) { |
147 ui::EventResult status = textfield_->OnGestureEvent(event); | 147 textfield_->OnGestureEvent(event); |
148 if (status != ui::ER_UNHANDLED) | 148 if (event->handled()) |
149 return status; | 149 return; |
150 | 150 |
151 switch (event->type()) { | 151 switch (event->type()) { |
152 case ui::ET_GESTURE_TAP_DOWN: | 152 case ui::ET_GESTURE_TAP_DOWN: |
153 OnBeforeUserAction(); | 153 OnBeforeUserAction(); |
154 textfield_->RequestFocus(); | 154 textfield_->RequestFocus(); |
155 // We don't deselect if the point is in the selection | 155 // We don't deselect if the point is in the selection |
156 // because TAP_DOWN may turn into a LONG_PRESS. | 156 // because TAP_DOWN may turn into a LONG_PRESS. |
157 if (!GetRenderText()->IsPointInSelection(event->location()) && | 157 if (!GetRenderText()->IsPointInSelection(event->location()) && |
158 MoveCursorTo(event->location(), false)) | 158 MoveCursorTo(event->location(), false)) |
159 SchedulePaint(); | 159 SchedulePaint(); |
160 OnAfterUserAction(); | 160 OnAfterUserAction(); |
161 return ui::ER_CONSUMED; | 161 event->SetHandled(); |
| 162 return; |
162 case ui::ET_GESTURE_DOUBLE_TAP: | 163 case ui::ET_GESTURE_DOUBLE_TAP: |
163 SelectAll(false); | 164 SelectAll(false); |
164 return ui::ER_CONSUMED; | 165 event->SetHandled(); |
| 166 return; |
165 case ui::ET_GESTURE_SCROLL_UPDATE: | 167 case ui::ET_GESTURE_SCROLL_UPDATE: |
166 OnBeforeUserAction(); | 168 OnBeforeUserAction(); |
167 if (MoveCursorTo(event->location(), true)) | 169 if (MoveCursorTo(event->location(), true)) |
168 SchedulePaint(); | 170 SchedulePaint(); |
169 OnAfterUserAction(); | 171 OnAfterUserAction(); |
170 return ui::ER_CONSUMED; | 172 event->SetHandled(); |
| 173 return; |
171 default: | 174 default: |
172 break; | 175 break; |
173 } | 176 } |
174 return TouchSelectionClientView::OnGestureEvent(event); | 177 TouchSelectionClientView::OnGestureEvent(event); |
175 } | 178 } |
176 | 179 |
177 bool NativeTextfieldViews::OnKeyPressed(const ui::KeyEvent& event) { | 180 bool NativeTextfieldViews::OnKeyPressed(const ui::KeyEvent& event) { |
178 // OnKeyPressed/OnKeyReleased/OnFocus/OnBlur will never be invoked on | 181 // OnKeyPressed/OnKeyReleased/OnFocus/OnBlur will never be invoked on |
179 // NativeTextfieldViews as it will never gain focus. | 182 // NativeTextfieldViews as it will never gain focus. |
180 NOTREACHED(); | 183 NOTREACHED(); |
181 return false; | 184 return false; |
182 } | 185 } |
183 | 186 |
184 bool NativeTextfieldViews::OnKeyReleased(const ui::KeyEvent& event) { | 187 bool NativeTextfieldViews::OnKeyReleased(const ui::KeyEvent& event) { |
(...skipping 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 // Filter out all control characters, including tab and new line characters, | 1265 // Filter out all control characters, including tab and new line characters, |
1263 // and all characters with Alt modifier. But we need to allow characters with | 1266 // and all characters with Alt modifier. But we need to allow characters with |
1264 // AltGr modifier. | 1267 // AltGr modifier. |
1265 // On Windows AltGr is represented by Alt+Ctrl, and on Linux it's a different | 1268 // On Windows AltGr is represented by Alt+Ctrl, and on Linux it's a different |
1266 // flag that we don't care about. | 1269 // flag that we don't care about. |
1267 return ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) && | 1270 return ((ch >= 0x20 && ch < 0x7F) || ch > 0x9F) && |
1268 (flags & ~(ui::EF_SHIFT_DOWN | ui::EF_CAPS_LOCK_DOWN)) != ui::EF_ALT_DOWN; | 1271 (flags & ~(ui::EF_SHIFT_DOWN | ui::EF_CAPS_LOCK_DOWN)) != ui::EF_ALT_DOWN; |
1269 } | 1272 } |
1270 | 1273 |
1271 } // namespace views | 1274 } // namespace views |
OLD | NEW |