fix: allow overlay mouse interaction outside its bounds#2921
Merged
hecrj merged 2 commits intoiced-rs:masterfrom May 2, 2025
Merged
fix: allow overlay mouse interaction outside its bounds#2921hecrj merged 2 commits intoiced-rs:masterfrom
hecrj merged 2 commits intoiced-rs:masterfrom
Conversation
The `mouse_interaction` method can be properly used now to encode hover status with the `None` and `Idle` variants.
hecrj
approved these changes
May 2, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change is related to this discussion on Discord.
This PR changes the overlay's
mouse_interactionso that it can still call this function for all open overlays even if the mouse is not over the overlay bounds. This is useful when implementing any sort of drag ability on a widget on an overlay.Currently if you try to have a widget like a slider that sets the
mouse_interactiontoInteraction::Grabbingwhen dragging the slider, this cursor wouldn't show as grabbing if you moved the mouse outside the overlay bounds while dragging. This doesn't seem to be the expected behavior, at lest not to me. I would expect the slider to keep moving and showing the correct cursor while I'm dragging it even if I move the mouse outside the overlay bounds. This PR fixes this.The issue was that the
mouse_interactionfunction wasn't even being called on an overlay if the mouse was outside it's borders. And even if it was there was still some code on theuser_interface.draw()function that wouldn't let you have theoverlay_interactionif the mouse wasn't over its bounds.The core team is busy and does not have time to mentor nor babysit new contributors. If a member of the core team thinks that reviewing and understanding your work will take more time and effort than writing it from scratch by themselves, your contribution will be dismissed. It is your responsibility to communicate and figure out how to reduce the likelihood of this!
Read the contributing guidelines for more details: https://github.com/iced-rs/iced/blob/master/CONTRIBUTING.md