| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/views/controls/combobox/combobox.h" | 5 #include "ui/views/controls/combobox/combobox.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 const char* Combobox::GetClassName() const { | 521 const char* Combobox::GetClassName() const { |
| 522 return kViewClassName; | 522 return kViewClassName; |
| 523 } | 523 } |
| 524 | 524 |
| 525 bool Combobox::SkipDefaultKeyEventProcessing(const ui::KeyEvent& e) { | 525 bool Combobox::SkipDefaultKeyEventProcessing(const ui::KeyEvent& e) { |
| 526 // Escape should close the drop down list when it is active, not host UI. | 526 // Escape should close the drop down list when it is active, not host UI. |
| 527 if (e.key_code() != ui::VKEY_ESCAPE || | 527 if (e.key_code() != ui::VKEY_ESCAPE || |
| 528 e.IsShiftDown() || e.IsControlDown() || e.IsAltDown()) { | 528 e.IsShiftDown() || e.IsControlDown() || e.IsAltDown()) { |
| 529 return false; | 529 return false; |
| 530 } | 530 } |
| 531 return menu_runner_; | 531 return !!menu_runner_; |
| 532 } | 532 } |
| 533 | 533 |
| 534 bool Combobox::OnKeyPressed(const ui::KeyEvent& e) { | 534 bool Combobox::OnKeyPressed(const ui::KeyEvent& e) { |
| 535 // TODO(oshima): handle IME. | 535 // TODO(oshima): handle IME. |
| 536 DCHECK_EQ(e.type(), ui::ET_KEY_PRESSED); | 536 DCHECK_EQ(e.type(), ui::ET_KEY_PRESSED); |
| 537 | 537 |
| 538 DCHECK_GE(selected_index_, 0); | 538 DCHECK_GE(selected_index_, 0); |
| 539 DCHECK_LT(selected_index_, model()->GetItemCount()); | 539 DCHECK_LT(selected_index_, model()->GetItemCount()); |
| 540 if (selected_index_ < 0 || selected_index_ > model()->GetItemCount()) | 540 if (selected_index_ < 0 || selected_index_ > model()->GetItemCount()) |
| 541 selected_index_ = 0; | 541 selected_index_ = 0; |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 return gfx::Size(width, font_list.GetHeight()); | 926 return gfx::Size(width, font_list.GetHeight()); |
| 927 } | 927 } |
| 928 | 928 |
| 929 PrefixSelector* Combobox::GetPrefixSelector() { | 929 PrefixSelector* Combobox::GetPrefixSelector() { |
| 930 if (!selector_) | 930 if (!selector_) |
| 931 selector_.reset(new PrefixSelector(this)); | 931 selector_.reset(new PrefixSelector(this)); |
| 932 return selector_.get(); | 932 return selector_.get(); |
| 933 } | 933 } |
| 934 | 934 |
| 935 } // namespace views | 935 } // namespace views |
| OLD | NEW |