Fix: `Response::clicked_elsewhere` takes clip rect into account (#4274)

`clicked_elsewhere` now checks against the clipped `interact_rect` of
the widget instead of the full `rect`.

In practice this shouldn't change much since the function is mostly used
for windows and areas, which aren't clipped.
This commit is contained in:
Emil Ernerfeldt 2024-03-30 10:35:55 +01:00 committed by GitHub
parent a7c5eb47a8
commit 8da0e8cc77
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 6 deletions

View File

@ -209,14 +209,10 @@ impl Response {
let pointer = &i.pointer;
if pointer.any_click() {
// We detect clicks/hover on a "interact_rect" that is slightly larger than
// self.rect. See Context::interact.
// This means we can be hovered and clicked even though `!self.rect.contains(pos)` is true,
// hence the extra complexity here.
if self.contains_pointer() {
if self.contains_pointer || self.hovered {
false
} else if let Some(pos) = pointer.interact_pos() {
!self.rect.contains(pos)
!self.interact_rect.contains(pos)
} else {
false // clicked without a pointer, weird
}