Commit d51700c2 authored by wutao's avatar wutao Committed by Commit Bot

cros: Handle ui::VKEY_BACK event to exit search mode in KSV.

This cl handles the ui::VKEY_BACK. If it is already empty search box and
typing ui::VKEY_BACK will exit search mode in Keyboard Shortcut
Viewer (KSV).

Bug: 768932
Test: Tested on device.
Change-Id: I5cee02a97959784163e65e300b5113f2a3409513
Reviewed-on: https://chromium-review.googlesource.com/923090
Commit-Queue: Tao Wu <wutao@chromium.org>
Reviewed-by: default avatarAhmed Fakhry <afakhry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537457}
parent dae4b834
...@@ -48,6 +48,8 @@ class KeyboardShortcutView : public views::WidgetDelegateView, ...@@ -48,6 +48,8 @@ class KeyboardShortcutView : public views::WidgetDelegateView,
void InitViews(); void InitViews();
// Put focus on the active tab. Used when the first time to show the widget or
// after exiting search mode.
void RequestFocusForActiveTab(); void RequestFocusForActiveTab();
static KeyboardShortcutView* GetInstanceForTesting(); static KeyboardShortcutView* GetInstanceForTesting();
......
...@@ -48,6 +48,20 @@ gfx::Size KSVSearchBoxView::CalculatePreferredSize() const { ...@@ -48,6 +48,20 @@ gfx::Size KSVSearchBoxView::CalculatePreferredSize() const {
return gfx::Size(704, 32); return gfx::Size(704, 32);
} }
void KSVSearchBoxView::OnKeyEvent(ui::KeyEvent* event) {
if (event->key_code() != ui::VKEY_BACK)
return;
if (!search_box()->text().empty())
return;
if (exit_search_mode_on_next_backspace_) {
SetSearchBoxActive(false);
event->SetHandled();
}
exit_search_mode_on_next_backspace_ = !exit_search_mode_on_next_backspace_;
}
void KSVSearchBoxView::UpdateBackgroundColor(SkColor color) { void KSVSearchBoxView::UpdateBackgroundColor(SkColor color) {
SetSearchBoxBackgroundColor(color); SetSearchBoxBackgroundColor(color);
} }
......
...@@ -22,6 +22,7 @@ class KSVSearchBoxView : public search_box::SearchBoxViewBase { ...@@ -22,6 +22,7 @@ class KSVSearchBoxView : public search_box::SearchBoxViewBase {
// views::View: // views::View:
gfx::Size CalculatePreferredSize() const override; gfx::Size CalculatePreferredSize() const override;
void OnKeyEvent(ui::KeyEvent* event) override;
private: private:
// search_box::SearchBoxViewBase: // search_box::SearchBoxViewBase:
...@@ -34,6 +35,9 @@ class KSVSearchBoxView : public search_box::SearchBoxViewBase { ...@@ -34,6 +35,9 @@ class KSVSearchBoxView : public search_box::SearchBoxViewBase {
void SetupCloseButton() override; void SetupCloseButton() override;
void SetupBackButton() override; void SetupBackButton() override;
// True to exit search mode on the next ui::VKEY_BACK event.
bool exit_search_mode_on_next_backspace_ = false;
DISALLOW_COPY_AND_ASSIGN(KSVSearchBoxView); DISALLOW_COPY_AND_ASSIGN(KSVSearchBoxView);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment