Index: views/controls/textfield/native_textfield_wrapper.h |
diff --git a/views/controls/textfield/native_textfield_wrapper.h b/views/controls/textfield/native_textfield_wrapper.h |
index eb5245fd7baf4f17f5d1d4ad412374a4d2aae9f9..c45243e029ed891cc600dccea6cec3f212ec5833 100644 |
--- a/views/controls/textfield/native_textfield_wrapper.h |
+++ b/views/controls/textfield/native_textfield_wrapper.h |
@@ -15,6 +15,7 @@ class Insets; |
namespace views { |
+class KeyEvent; |
class Textfield; |
class View; |
@@ -77,8 +78,9 @@ class NativeTextfieldWrapper { |
// Updates the vertical margins for the native text field. |
virtual void UpdateVerticalMargins() = 0; |
- // Sets the focus to the text field. |
- virtual void SetFocus() = 0; |
+ // Sets the focus to the text field. Returns false if the wrapper |
+ // didn't take focus. |
+ virtual bool SetFocus() = 0; |
// Retrieves the views::View that hosts the native control. |
virtual View* GetView() = 0; |
@@ -89,6 +91,23 @@ class NativeTextfieldWrapper { |
// Returns whether or not an IME is composing text. |
virtual bool IsIMEComposing() const = 0; |
+ // Following methods are to forward key/focus related events to the |
+ // views wrapper so that TextfieldViews can handle key inputs without |
+ // having focus. |
+ |
+ // Invoked when a key is pressed/release on Textfield. Subclasser |
+ // should return true if the event has been processed and false |
+ // otherwise. |
+ // See also View::OnKeyPressed/OnKeyReleased. |
+ virtual bool HandleKeyPressed(const views::KeyEvent& e) = 0; |
+ virtual bool HandleKeyReleased(const views::KeyEvent& e) = 0; |
+ |
+ // Invoked when focus is being moved from or to the Textfield. |
+ // See also View::WillGainFocus/DidGainFocus/WillLoseFocus. |
+ virtual void HandleWillGainFocus() = 0; |
+ virtual void HandleDidGainFocus() = 0; |
+ virtual void HandleWillLoseFocus() = 0; |
+ |
// Creates an appropriate NativeTextfieldWrapper for the platform. |
static NativeTextfieldWrapper* CreateWrapper(Textfield* field); |
}; |