summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/views/accelerator.h4
-rw-r--r--chrome/views/controls/combo_box.cc13
-rw-r--r--chrome/views/controls/combo_box.h1
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);