OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_CONTROLLER_H_ | 5 #ifndef VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_CONTROLLER_H_ |
6 #define VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_CONTROLLER_H_ | 6 #define VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_CONTROLLER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/string16.h" | 9 #include "base/string16.h" |
10 | 10 |
11 namespace views { | 11 namespace views { |
12 | 12 |
13 class KeyEvent; | 13 class KeyEvent; |
14 class Textfield; | 14 class Textfield; |
15 | 15 |
16 // This defines the callback interface for other code to be notified of changes | 16 // This defines the callback interface for other code to be notified of changes |
17 // in the state of a text field. | 17 // in the state of a text field. |
18 class TextfieldController { | 18 class TextfieldController { |
19 public: | 19 public: |
20 // This method is called whenever the text in the field changes. | 20 // This method is called whenever the text in the field changes. |
21 virtual void ContentsChanged(Textfield* sender, | 21 virtual void ContentsChanged(Textfield* sender, |
22 const string16& new_contents) = 0; | 22 const string16& new_contents) = 0; |
23 | 23 |
24 // This method is called to get notified about keystrokes in the edit. | 24 // This method is called to get notified about keystrokes in the edit. |
25 // Returns true if the message was handled and should not be processed | 25 // Returns true if the message was handled and should not be processed |
26 // further. If it returns false the processing continues. | 26 // further. If it returns false the processing continues. |
27 virtual bool HandleKeyEvent(Textfield* sender, | 27 virtual bool HandleKeyEvent(Textfield* sender, |
28 const KeyEvent& key_event) = 0; | 28 const KeyEvent& key_event) = 0; |
| 29 |
| 30 // Called before performing a user action that may change the textfield. |
| 31 // It's currently only supported by Views implementation. |
| 32 virtual void OnBeforeUserAction(Textfield* sender) {} |
| 33 |
| 34 // Called after performing a user action that may change the textfield. |
| 35 // It's currently only supported by Views implementation. |
| 36 virtual void OnAfterUserAction(Textfield* sender) {} |
| 37 |
| 38 protected: |
| 39 virtual ~TextfieldController() {} |
29 }; | 40 }; |
30 | 41 |
31 } // namespace views | 42 } // namespace views |
32 | 43 |
33 #endif // VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_CONTROLLER_H_ | 44 #endif // VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_CONTROLLER_H_ |
OLD | NEW |