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

API request: add OnChangeEnded API to the Slider widget #3652

Closed
2 tasks done
dweymouth opened this issue Feb 10, 2023 · 6 comments · Fixed by #3801
Closed
2 tasks done

API request: add OnChangeEnded API to the Slider widget #3652

dweymouth opened this issue Feb 10, 2023 · 6 comments · Fixed by #3801
Labels
enhancement New feature or request optimization Tickets that could help Fyne apps run faster

Comments

@dweymouth
Copy link
Contributor

Checklist

  • I have searched the issue tracker for open issues that relate to the same feature, before opening a new one.
  • This issue only relates to a single feature. I will open new issues for any other features.

Is your feature request related to a problem?

In some apps it is necessary to differentiate ValueChanged events to a slider that are occurring during a drag action, vs a ValueChanged that occurs at the end of a user interaction, in order to trigger backend logic only in the 2nd case.

Is it possible to construct a solution with the existing API?

Yes, by extending Slider, overriding DragEnd (and later overriding Tapped as well once tap-to-set support lands in the slider widget), to keep track of when the user interaction ends yourself

Describe the solution you'd like to see.

A new callback API to the slider widget OnChangeEnded func() which allows application code to be notified when a user interaction that is changing the slider value has completed. Maybe the signature should be OnChangeEnded func(float) where the last set value is passed as well

@dweymouth
Copy link
Contributor Author

dweymouth commented Feb 10, 2023

Actually maybe adding an OnChangeStarted func() should be considered as well - a callback invoked when a single user interaction begins that may last for some time and change the value multiple times. I had forgot that I had custom logic in my extended slider to handle this as well, since I needed to stop automatically updating the play time label while a slider drag was going on

The use case for this one is a little less widespread though, I'd imagine

@Jacalz
Copy link
Member

Jacalz commented Feb 10, 2023

I have actually thought about if we instead should try to change the behavior to trigger the OnChanged at the drag end. My personal opinion is that the user hasn't actually "selected" a value until the drag has ended. I not so sure that adding more OnChangedXyz functions is the best option.

@dweymouth
Copy link
Contributor Author

In some cases it's useful to respond to valueChanged during the drag. e.g. a color slider, or in my app's case, a volume slider that can update the volume during a drag. (my seek slider only invokes the action on drag end though). Andy and I discussed this a bit in Discord

@Jacalz
Copy link
Member

Jacalz commented Feb 10, 2023

Hmm. Interesting. I have never personally found any use for having it update continuously but your usage seems very sensible. Having a OnChangeEnded func(float) seems like it could be a good addition in that case :)

@Jacalz Jacalz added enhancement New feature or request optimization Tickets that could help Fyne apps run faster labels Feb 10, 2023
@Jacalz
Copy link
Member

Jacalz commented Feb 10, 2023

I'm also adding the performance tag as this can be useful for developers to avoid having many OnChanged calls when it isn't necessary to do so.

@andydotxyz
Copy link
Member

Landed on develop thanks @dweymouth

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request optimization Tickets that could help Fyne apps run faster
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants