From 6a5d60cb0eba921af8e79e80cb6c8abaa6d8c68e Mon Sep 17 00:00:00 2001 From: "jcampan@chromium.org" Date: Tue, 5 May 2009 18:55:56 +0000 Subject: 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 --- chrome/views/accelerator.h | 4 ++++ chrome/views/controls/combo_box.cc | 13 +++++++++++++ chrome/views/controls/combo_box.h | 1 + 3 files changed, 18 insertions(+) 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); -- cgit v1.1