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 is changed by the |
| 21 // user. It won't be called if the text is changed by calling |
| 22 // Textfield::SetText() or Textfield::AppendText(). |
21 virtual void ContentsChanged(Textfield* sender, | 23 virtual void ContentsChanged(Textfield* sender, |
22 const string16& new_contents) = 0; | 24 const string16& new_contents) = 0; |
23 | 25 |
24 // This method is called to get notified about keystrokes in the edit. | 26 // 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 | 27 // Returns true if the message was handled and should not be processed |
26 // further. If it returns false the processing continues. | 28 // further. If it returns false the processing continues. |
27 virtual bool HandleKeyEvent(Textfield* sender, | 29 virtual bool HandleKeyEvent(Textfield* sender, |
28 const KeyEvent& key_event) = 0; | 30 const KeyEvent& key_event) = 0; |
29 | 31 |
30 // Called before performing a user action that may change the textfield. | 32 // Called before performing a user action that may change the textfield. |
31 // It's currently only supported by Views implementation. | 33 // It's currently only supported by Views implementation. |
32 virtual void OnBeforeUserAction(Textfield* sender) {} | 34 virtual void OnBeforeUserAction(Textfield* sender) {} |
33 | 35 |
34 // Called after performing a user action that may change the textfield. | 36 // Called after performing a user action that may change the textfield. |
35 // It's currently only supported by Views implementation. | 37 // It's currently only supported by Views implementation. |
36 virtual void OnAfterUserAction(Textfield* sender) {} | 38 virtual void OnAfterUserAction(Textfield* sender) {} |
37 | 39 |
38 protected: | 40 protected: |
39 virtual ~TextfieldController() {} | 41 virtual ~TextfieldController() {} |
40 }; | 42 }; |
41 | 43 |
42 } // namespace views | 44 } // namespace views |
43 | 45 |
44 #endif // VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_CONTROLLER_H_ | 46 #endif // VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_CONTROLLER_H_ |
OLD | NEW |