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

Unified Diff: Source/devtools/front_end/ui/SettingsUI.js

Issue 365923002: [DevTools] Allow arrow keys to increment/decrement value in numeric inputs. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 6 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/ui/SettingsUI.js
diff --git a/Source/devtools/front_end/ui/SettingsUI.js b/Source/devtools/front_end/ui/SettingsUI.js
index 03f6748b46f0faf05bdbaba2e36ad1c93799ffec..1f758630278165edfba04737362ac25b302d0f82 100644
--- a/Source/devtools/front_end/ui/SettingsUI.js
+++ b/Source/devtools/front_end/ui/SettingsUI.js
@@ -132,6 +132,36 @@ WebInspector.SettingsUI.createSettingInputField = function(label, setting, numer
{
if (isEnterKey(event))
apply();
+ incrementForArrows(event);
+ }
+
+ function incrementForArrows(event)
+ {
+ if (!numeric)
+ return;
+
+ var increment = event.keyIdentifier === "Up" ? 1 : event.keyIdentifier === "Down" ? -1 : 0;
+ if (!increment)
+ return;
+ if (event.shiftKey)
+ increment *= 10;
+
+ var value = inputElement.value;
+ if (validatorCallback && validatorCallback(value))
vsevik 2014/07/02 15:17:25 Looks like this is not really needed.
dgozman 2014/07/02 15:50:17 This is to do nothing if user enters "abc" and pre
+ return;
+ value = Number(value);
+ if (clearForZero && !value)
vsevik 2014/07/02 15:17:25 So we'll never increment zero?
dgozman 2014/07/02 15:50:17 Yes, if we replace zero value by empty string (use
+ return;
+ value += increment;
+ if (clearForZero && !value)
vsevik 2014/07/02 15:17:25 Why?
dgozman 2014/07/02 15:50:17 Same reasons. I don't want to switch from "1" to e
+ return;
+ value = String(value);
+ if (validatorCallback && validatorCallback(value))
+ return;
+
+ inputElement.value = value;
+ apply();
+ event.preventDefault();
}
function validate()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698