Skip to content

Add on_release message to Slider#378

Merged
hecrj merged 5 commits into
iced-rs:masterfrom
Masterchef365:master
Jun 8, 2020
Merged

Add on_release message to Slider#378
hecrj merged 5 commits into
iced-rs:masterfrom
Masterchef365:master

Conversation

@Masterchef365
Copy link
Copy Markdown
Contributor

Sometimes, it's useful to have a message fire only when the user has finished changing a parameter. Other widgets like text inputs may also benefit from this functionality, and I'd be happy to implement those as well!

Copy link
Copy Markdown
Member

@hecrj hecrj left a comment

Choose a reason for hiding this comment

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

Thanks!

I think this may be a nice addition. Do you have any specific use cases in mind for this?

Comment thread native/src/widget/slider.rs Outdated
Comment thread native/src/widget/slider.rs Outdated
Comment thread native/src/widget/slider.rs
@Masterchef365 Masterchef365 changed the title Add on_finish callback to Slider Add on_release message to Slider Jun 3, 2020
@Masterchef365
Copy link
Copy Markdown
Contributor Author

Incorporated the changes you suggested into it; had to make the message impl Clone but I assume that's not a big deal since Button requires it too. Added a bit of an explanation for the on_release message as well; the use case I have is that a long running task (actually a whole thread) is spawned to perform an update to a large amount of data every time the slider is changed. on_change would fire that event every time a mouse position update was detected, and the result was that my app suddenly used 100% of all cores every time the slider was moved. I could've solved this by limiting when the thread could be spawned, but that wasn't exactly the behavior I wanted.

Comment thread native/src/widget/slider.rs
@hecrj hecrj added the feature New feature or request label Jun 4, 2020
@hecrj hecrj added this to the 0.2.0 milestone Jun 4, 2020
Copy link
Copy Markdown
Member

@hecrj hecrj left a comment

Choose a reason for hiding this comment

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

Great! Thank you 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants