-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add up/down keys to inc/dec val in editor spin slider #41855
Add up/down keys to inc/dec val in editor spin slider #41855
Conversation
For consistency with web browsers' DevTools, we could use the same modifiers to increment/decrement values:
https://kilianvalkhof.com/2020/javascript/supercharging-input-type-number/ |
I can add the extra modifiers, sure!
Looks like Ctrl/Cmd has priority, shift second, then alt, and alt is ignored on integers. |
An issue occurs with using devtools style is that in GDScript, you can export a variable with a given step. I.E. @export_range(0, 100, 0.5)
var my_exported_range = 50.0 So the question occurs: if pressing up does 0.5, if the user holds down CTRL/CMD, SHIFT or ALT and presses up, how does the number react? 50.0, 5.0, 0.5, 0.05? The default step for floating point numbers is 0.001, furthermore. Unless we force the values to 100, 10, 1, 0.1, that makes even ctrl/cmd have only a small effect. EDIT: One suggestion is to make modifier-less up and down use step, and the rest go with their devtool style of 100, 10 and 0.1. |
5079960
to
6d2e332
Compare
6d2e332
to
92a4471
Compare
92a4471
to
900a9b3
Compare
Any chance we can seem some action here again? I still press up and down when selecting items in the inspector and I always remember about this PR 🙈 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on the latest master
branch (after rebasing), it works as intended. Looks good from an UX and implementation perspective.
However, with floating-point properties, changing the value using Up/Down without holding any modifiers will change the value by the smallest allowed step (typically 0.001). We should change this so that the step is always 1 when not using a modifier, for consistency with integer properties.
The issue with that is that it steps on the toes of the export hint. I.E.: export(float, 100, 1000, 20) var value: float will make up and down go by steps of 20 because the inspector has it as its value. If someone sets theirs to 0.25, but we force it to 1, that creates a dissonance. |
a4dc8c0
to
35d39af
Compare
For the keyboard shortcuts, I was thinking we should use "our" float step of 1 whenever the property's float step is an integer divisor of 1 (1/2 = 0.5, 1/4 = 0.25, 1/8 = 0.125, …). The default float step (0.001) is 1/1000, so it works here 🙂 When a modifier key tries to set a value not allowed by the float step, it tries to round using If it's not a divisor, we should use the property's float step instead. |
cb222e8
to
5194de4
Compare
47e0ab7
to
e36fd69
Compare
Finally got back to this. As suggested by Calinou, it will treat <1 values that are integer divisors as 1, though will use the real step for >1 or when the step causes an invalid value (I.E. a step of 0.25 trying to increase by 0.1 would cause no increase otherwise.) |
0d92615
to
d253f91
Compare
d253f91
to
3e18cc2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I did not get perfectly the logic for choosing hte right value, but the implementation looks good otherwise.
Thanks! |
Adds the ability to increment and decrement an integer while focused in the editor spin slider's line edit, via a gui_input event. Also works with shift to increment and decrement by x10, alt for x0.1, and control/command for x100.
Bugsquad edit: This closes godotengine/godot-proposals#29.