| 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 #ifndef UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_CONTROLLER_H_ | 5 #ifndef UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_CONTROLLER_H_ |
| 6 #define UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_CONTROLLER_H_ | 6 #define UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_CONTROLLER_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| 11 #include "ui/base/dragdrop/os_exchange_data.h" | 11 #include "ui/base/dragdrop/os_exchange_data.h" |
| 12 #include "ui/views/views_export.h" | 12 #include "ui/views/views_export.h" |
| 13 | 13 |
| 14 namespace ui { | 14 namespace ui { |
| 15 class KeyEvent; | 15 class KeyEvent; |
| 16 class MouseEvent; | 16 class MouseEvent; |
| 17 class GestureEvent; |
| 17 class SimpleMenuModel; | 18 class SimpleMenuModel; |
| 18 } // namespace ui | 19 } // namespace ui |
| 19 | 20 |
| 20 namespace views { | 21 namespace views { |
| 21 | 22 |
| 22 class Textfield; | 23 class Textfield; |
| 23 | 24 |
| 24 // This defines the callback interface for other code to be notified of changes | 25 // This defines the callback interface for other code to be notified of changes |
| 25 // in the state of a text field. | 26 // in the state of a text field. |
| 26 class VIEWS_EXPORT TextfieldController { | 27 class VIEWS_EXPORT TextfieldController { |
| 27 public: | 28 public: |
| 28 // This method is called whenever the text in the field is changed by the | 29 // This method is called whenever the text in the field is changed by the |
| 29 // user. It won't be called if the text is changed by calling | 30 // user. It won't be called if the text is changed by calling |
| 30 // Textfield::SetText() or Textfield::AppendText(). | 31 // Textfield::SetText() or Textfield::AppendText(). |
| 31 virtual void ContentsChanged(Textfield* sender, | 32 virtual void ContentsChanged(Textfield* sender, |
| 32 const base::string16& new_contents) {} | 33 const base::string16& new_contents) {} |
| 33 | 34 |
| 34 // This method is called to get notified about keystrokes in the edit. | 35 // Called to get notified about keystrokes in the edit. |
| 35 // Returns true if the message was handled and should not be processed | 36 // Returns true if the message was handled and should not be processed |
| 36 // further. If it returns false the processing continues. | 37 // further. If it returns false the processing continues. |
| 37 virtual bool HandleKeyEvent(Textfield* sender, | 38 virtual bool HandleKeyEvent(Textfield* sender, |
| 38 const ui::KeyEvent& key_event); | 39 const ui::KeyEvent& key_event); |
| 39 | 40 |
| 40 // This method is called to get notified about mouse events in the edit. | 41 // Called to get notified about mouse events in the edit. |
| 41 // Returns true if the message was handled and should not be processed | 42 // Returns true if the message was handled and should not be processed |
| 42 // further. Currently, only mouse down events are sent here. | 43 // further. Currently, only mouse down events are sent here. |
| 43 virtual bool HandleMouseEvent(Textfield* sender, | 44 virtual bool HandleMouseEvent(Textfield* sender, |
| 44 const ui::MouseEvent& mouse_event); | 45 const ui::MouseEvent& mouse_event); |
| 45 | 46 |
| 47 // Called to get notified about gesture events in the edit. |
| 48 // Returns true if the message was handled and should not be processed |
| 49 // further. Currently, only tap events are sent here. |
| 50 virtual bool HandleGestureEvent(Textfield* sender, |
| 51 const ui::GestureEvent& gesture_event); |
| 52 |
| 46 // Called before performing a user action that may change the textfield. | 53 // Called before performing a user action that may change the textfield. |
| 47 // It's currently only supported by Views implementation. | 54 // It's currently only supported by Views implementation. |
| 48 virtual void OnBeforeUserAction(Textfield* sender) {} | 55 virtual void OnBeforeUserAction(Textfield* sender) {} |
| 49 | 56 |
| 50 // Called after performing a user action that may change the textfield. | 57 // Called after performing a user action that may change the textfield. |
| 51 // It's currently only supported by Views implementation. | 58 // It's currently only supported by Views implementation. |
| 52 virtual void OnAfterUserAction(Textfield* sender) {} | 59 virtual void OnAfterUserAction(Textfield* sender) {} |
| 53 | 60 |
| 54 // Called after performing a Cut or Copy operation. | 61 // Called after performing a Cut or Copy operation. |
| 55 virtual void OnAfterCutOrCopy(ui::ClipboardType clipboard_type) {} | 62 virtual void OnAfterCutOrCopy(ui::ClipboardType clipboard_type) {} |
| (...skipping 23 matching lines...) Expand all Loading... |
| 79 // Gives the controller a chance to modify the context menu contents. | 86 // Gives the controller a chance to modify the context menu contents. |
| 80 virtual void UpdateContextMenu(ui::SimpleMenuModel* menu_contents) {} | 87 virtual void UpdateContextMenu(ui::SimpleMenuModel* menu_contents) {} |
| 81 | 88 |
| 82 protected: | 89 protected: |
| 83 virtual ~TextfieldController() {} | 90 virtual ~TextfieldController() {} |
| 84 }; | 91 }; |
| 85 | 92 |
| 86 } // namespace views | 93 } // namespace views |
| 87 | 94 |
| 88 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_CONTROLLER_H_ | 95 #endif // UI_VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_CONTROLLER_H_ |
| OLD | NEW |