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

Add hovered_anyway() to Response to deal with child widgets events when hovered #907

Closed
wants to merge 2 commits into from

Conversation

imxood
Copy link

@imxood imxood commented Nov 23, 2021

Add hovered_anyway() to Response, this can help to deal with child widgets events when current widget is hovered

usage

image

image

@imxood imxood changed the title Add hovered_anyway() to Response, this can help to deal with child widgets events Add hovered_anyway() to Response, deal with child widgets events when hovered Nov 23, 2021
@imxood imxood changed the title Add hovered_anyway() to Response, deal with child widgets events when hovered Add hovered_anyway() to Response to deal with child widgets events when hovered Nov 23, 2021
pub fn hovered_anyway(&self) -> bool {
let pointer = &self.ctx.input().pointer;
if let Some(pos) = pointer.interact_pos() {
self.rect.contains(pos)
Copy link
Owner

Choose a reason for hiding this comment

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

this will return true even if another egui window is covering your widget. is this really intentional?

Copy link
Author

Choose a reason for hiding this comment

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

I didn't think so much ....

Copy link
Owner

Choose a reason for hiding this comment

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

What is your use case? Would fn hovered_or_clicked(&self) -> bool { self.hovered() || self.clicked() } handle it?

Copy link
Author

Choose a reason for hiding this comment

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

I want to realize that when hovering the current component, it can display the sub-components, such as "delete button"

image
image

@emilk
Copy link
Owner

emilk commented Dec 28, 2021

I think something like this is a better solution: #1010

@emilk emilk closed this Dec 28, 2021
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.

2 participants