diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-05 18:55:56 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-05 18:55:56 +0000 |
commit | 6a5d60cb0eba921af8e79e80cb6c8abaa6d8c68e (patch) | |
tree | c8feb27a2efd71f838c5be6281892c5ef3a11e92 | |
parent | c93a0456024db87edcd92ef8c34de008afb42356 (diff) | |
download | chromium_src-6a5d60cb0eba921af8e79e80cb6c8abaa6d8c68e.zip chromium_src-6a5d60cb0eba921af8e79e80cb6c8abaa6d8c68e.tar.gz chromium_src-6a5d60cb0eba921af8e79e80cb6c8abaa6d8c68e.tar.bz2 |
Landing the CL from Yusukes.
See http://codereview.chromium.org/99311
TBR=yusukes
Review URL: http://codereview.chromium.org/109030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@15317 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/views/accelerator.h | 4 | ||||
-rw-r--r-- | chrome/views/controls/combo_box.cc | 13 | ||||
-rw-r--r-- | chrome/views/controls/combo_box.h | 1 |
3 files changed, 18 insertions, 0 deletions
diff --git a/chrome/views/accelerator.h b/chrome/views/accelerator.h index 867423c..a851b0c 100644 --- a/chrome/views/accelerator.h +++ b/chrome/views/accelerator.h @@ -58,6 +58,10 @@ class Accelerator { return (key_code_ == rhs.key_code_) && (modifiers_ == rhs.modifiers_); } + bool operator !=(const Accelerator& rhs) const { + return !(*this == rhs); + } + bool IsShiftDown() const { return (modifiers_ & Event::EF_SHIFT_DOWN) == Event::EF_SHIFT_DOWN; } diff --git a/chrome/views/controls/combo_box.cc b/chrome/views/controls/combo_box.cc index 6d62fce..eaf8a07 100644 --- a/chrome/views/controls/combo_box.cc +++ b/chrome/views/controls/combo_box.cc @@ -67,6 +67,19 @@ gfx::Size ComboBox::GetPreferredSize() { return gfx::Size(pref_width, pref_height); } +// VK_ESCAPE should be handled by this view when the drop down list is active. +// In other words, the list should be closed instead of the dialog. +bool ComboBox::OverrideAccelerator(const Accelerator& accelerator) { + if (accelerator != Accelerator(VK_ESCAPE, false, false, false)) + return false; + + HWND hwnd = GetNativeControlHWND(); + if (!hwnd) + return false; + + return ::SendMessage(hwnd, CB_GETDROPPEDSTATE, 0, 0) != 0; +} + HWND ComboBox::CreateNativeControl(HWND parent_container) { HWND r = ::CreateWindowEx(GetAdditionalExStyle(), L"COMBOBOX", L"", WS_CHILD | WS_VSCROLL | CBS_DROPDOWNLIST, diff --git a/chrome/views/controls/combo_box.h b/chrome/views/controls/combo_box.h index 11e2777..826caec 100644 --- a/chrome/views/controls/combo_box.h +++ b/chrome/views/controls/combo_box.h @@ -42,6 +42,7 @@ class ComboBox : public NativeControl { // Overridden from View. virtual gfx::Size GetPreferredSize(); + virtual bool OverrideAccelerator(const Accelerator& accelerator); // Overridden from NativeControl virtual HWND CreateNativeControl(HWND parent_container); |