Skip to content
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

DragValue: when keyboard editing, only update the value on focus lost #2688

Merged
merged 5 commits into from
Feb 8, 2023

Conversation

harrisonmg
Copy link
Contributor

Closes #2687

Since the underlying TextEdit is singleline, pressing enter also results in lost focus.

I demonstrate two instances of this below. I press enter after the first edit, then click away after the second.

demo

I also shuffled some of the accesskit stuff. The up and down arrow keys probably shouldn't change the value during keyboard editing either. That little change allowed me to consolidate the accesskit code a bit better. I'm not sure how to test it.

As far as testing goes, ./sh/check.sh failed in my environment (WSL 2) for some winit / platform reason. Clippy has no complaints about my changes.

@emilk
Copy link
Owner

emilk commented Feb 7, 2023

The up and down arrow keys probably shouldn't change the value during keyboard editing either.

Actually, it is very convenient to be able to move keyboard focus to DragValue using Tab, and then and press up/down to change its value! I'd prefer to keep that behavior.

Copy link
Owner

@emilk emilk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the addition of if response.lost_focus() - it is really a much better behavior - but please revert the change where you can no longer change the value with up/down

if let Some(parsed_value) = parsed_value {
let parsed_value = clamp_to_range(parsed_value, clamp_range.clone());
set(&mut get_set_value, parsed_value);
if response.lost_focus() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice if you also added a comment justifying why this check should be done. The fact that it was absent before allows us to conclude that it is not self evident. Description of the reasons why this check was added and what it affects will make it easier to resolve problems if this change leads to them.

A good tone will also leave a link to the GitHub Issue, where you can get more information.

@emilk emilk merged commit b40dba1 into emilk:master Feb 8, 2023
@harrisonmg harrisonmg deleted the drag_value_only_update_on_focus_lost branch February 8, 2023 13:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

During keyboard input, only update a DragValue value when focus is lost.
3 participants