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

Unified Diff: views/controls/textfield/textfield.cc

Issue 200035: First cut at implementation of FindBar for views / gtk... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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
Index: views/controls/textfield/textfield.cc
===================================================================
--- views/controls/textfield/textfield.cc (revision 25765)
+++ views/controls/textfield/textfield.cc (working copy)
@@ -4,10 +4,15 @@
#include "views/controls/textfield/textfield.h"
+#if defined(OS_LINUX)
+#include <gdk/gdkkeysyms.h>
+#endif
+
#include "app/gfx/insets.h"
#if defined(OS_WIN)
#include "app/win_util.h"
#endif
+
#include "base/string_util.h"
#include "views/controls/textfield/native_textfield_wrapper.h"
#include "views/widget/widget.h"
@@ -167,28 +172,6 @@
text_ = native_wrapper_->GetText();
}
-// static
-bool Textfield::IsKeystrokeEnter(const Keystroke& key) {
-#if defined(OS_WIN)
- return key.key == VK_RETURN;
-#else
- // TODO(port): figure out VK_constants
- NOTIMPLEMENTED();
- return false;
-#endif
-}
-
-// static
-bool Textfield::IsKeystrokeEscape(const Keystroke& key) {
-#if defined(OS_WIN)
- return key.key == VK_ESCAPE;
-#else
- // TODO(port): figure out VK_constants
- NOTIMPLEMENTED();
- return false;
-#endif
-}
-
////////////////////////////////////////////////////////////////////////////////
// Textfield, View overrides:
@@ -296,4 +279,32 @@
return native_wrapper;
}
+base::KeyboardCode Textfield::Keystroke::GetKeyboardCode() const {
+#if defined(OS_WIN)
+ return static_cast<base::KeyboardCode>(key_));
+#else
+ return static_cast<base::KeyboardCode>(event_.keyval);
+#endif
+}
+
+#if defined(OS_WIN)
+bool Textfield::Keystroke::IsControlHeld() const {
+ return GetKeyState(VK_CONTROL) >= 0;
+}
+
+bool Textfield::Keystroke::IsShiftHeld() const {
+ return GetKeyState(VK_SHIFT) >= 0;
+}
+#else
+bool Textfield::Keystroke::IsControlHeld() const {
+ return (event_.state & gtk_accelerator_get_default_mod_mask()) ==
+ GDK_CONTROL_MASK;
+}
+
+bool Textfield::Keystroke::IsShiftHeld() const {
+ return (event_.state & gtk_accelerator_get_default_mod_mask()) ==
+ GDK_SHIFT_MASK;
+}
+#endif
+
} // namespace views

Powered by Google App Engine
This is Rietveld 408576698