Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(886)

Unified Diff: ui/views/controls/slider.cc

Issue 2717583002: Improve views::Slider keyboard handling. (Closed)
Patch Set: add test coverage Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/views/controls/slider_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/views/controls/slider.cc
diff --git a/ui/views/controls/slider.cc b/ui/views/controls/slider.cc
index 219ebf6c02195dff7fb3096b33e49f5de41bd282..eacd6aa2644ac757da76faf026f69af121d36218 100644
--- a/ui/views/controls/slider.cc
+++ b/ui/views/controls/slider.cc
@@ -243,14 +243,26 @@ void Slider::OnMouseReleased(const ui::MouseEvent& event) {
}
bool Slider::OnKeyPressed(const ui::KeyEvent& event) {
- float new_value = value_;
- if (event.key_code() == ui::VKEY_LEFT)
- new_value -= keyboard_increment_;
- else if (event.key_code() == ui::VKEY_RIGHT)
- new_value += keyboard_increment_;
- else
- return false;
- SetValueInternal(new_value, VALUE_CHANGED_BY_USER);
+ int direction = 1;
+ switch (event.key_code()) {
+ case ui::VKEY_LEFT:
+ direction = base::i18n::IsRTL() ? 1 : -1;
+ break;
+ case ui::VKEY_RIGHT:
+ direction = base::i18n::IsRTL() ? -1 : 1;
+ break;
+ case ui::VKEY_UP:
+ direction = 1;
+ break;
+ case ui::VKEY_DOWN:
+ direction = -1;
+ break;
+
+ default:
+ return false;
+ }
+ SetValueInternal(value_ + direction * keyboard_increment_,
+ VALUE_CHANGED_BY_USER);
return true;
}
« no previous file with comments | « no previous file | ui/views/controls/slider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698