Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(321)

Unified Diff: views/controls/textfield/native_textfield_views.h

Issue 6267002: Implement double/triple click functionality in views textfield. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: refactoring Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | views/controls/textfield/native_textfield_views.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: views/controls/textfield/native_textfield_views.h
diff --git a/views/controls/textfield/native_textfield_views.h b/views/controls/textfield/native_textfield_views.h
index d474a72b6dd5c6b1fc774d3361d1777313f987a7..fb567cf55b1b1c02c7aabb4b9b365424cf8780f0 100644
--- a/views/controls/textfield/native_textfield_views.h
+++ b/views/controls/textfield/native_textfield_views.h
@@ -14,6 +14,10 @@
#include "views/controls/textfield/native_textfield_wrapper.h"
#include "views/view.h"
+namespace base {
+class Time;
+}
+
namespace gfx {
class Canvas;
} // namespace
@@ -108,6 +112,13 @@ class NativeTextfieldViews : public views::View,
// Enable/Disable TextfieldViews implementation for Textfield.
static void SetEnableTextfieldViews(bool enabled);
+ enum ClickState {
+ TRACKING_DOUBLE_CLICK,
+ TRACKING_TRIPLE_CLICK,
+ NONE,
+ };
+
+
private:
friend class NativeTextfieldViewsTest;
@@ -162,6 +173,13 @@ class NativeTextfieldViews : public views::View,
// Find a cusor position for given |point| in this views coordinates.
size_t FindCursorPosition(const gfx::Point& point) const;
+ // Mouse event handler. Returns true if textfield needs to be repainted.
+ bool HandleMousePressed(const views::MouseEvent& e);
+
+ // Helper function that sets the cursor position at the location of mouse
+ // event.
+ void SetCursorForMouseClick(const views::MouseEvent& e);
+
// Utility function to inform the parent textfield (and its controller if any)
// that the text in the textfield has changed.
void PropagateTextChange();
@@ -193,6 +211,15 @@ class NativeTextfieldViews : public views::View,
// A runnable method factory for callback to update the cursor.
ScopedRunnableMethodFactory<NativeTextfieldViews> cursor_timer_;
+ // Time of last LEFT mouse press. Used for tracking double/triple click.
+ base::Time last_mouse_press_time_;
+
+ // Position of last LEFT mouse press. Used for tracking double/triple click.
+ gfx::Point last_mouse_press_location_;
+
+ // State variable to track double and triple clicks.
+ ClickState click_state_;
+
// Context menu and its content list for the textfield.
scoped_ptr<ui::SimpleMenuModel> context_menu_contents_;
scoped_ptr<Menu2> context_menu_menu_;
« no previous file with comments | « no previous file | views/controls/textfield/native_textfield_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698