Tune the focus-visible heuristics a bit (#41314)

This isn't quite right yet, as a proper solution would remember the
input modality at the moment of focus change, rather than at painting
time. But this gets us close enough for now.

Release Notes:

- N/A
This commit is contained in:
Mikayla Maki
2025-10-27 19:53:53 +00:00
committed by GitHub
parent 58f07ff709
commit ac3d2a338b
2 changed files with 38 additions and 9 deletions
+22
View File
@@ -115,6 +115,16 @@ impl InputEvent for MouseDownEvent {
}
impl MouseEvent for MouseDownEvent {}
impl MouseDownEvent {
/// Returns true if this mouse up event should focus the element.
pub fn is_focusing(&self) -> bool {
match self.button {
MouseButton::Left => true,
_ => false,
}
}
}
/// A mouse up event from the platform
#[derive(Clone, Debug, Default)]
pub struct MouseUpEvent {
@@ -137,8 +147,19 @@ impl InputEvent for MouseUpEvent {
PlatformInput::MouseUp(self)
}
}
impl MouseEvent for MouseUpEvent {}
impl MouseUpEvent {
/// Returns true if this mouse up event should focus the element.
pub fn is_focusing(&self) -> bool {
match self.button {
MouseButton::Left => true,
_ => false,
}
}
}
/// A click event, generated when a mouse button is pressed and released.
#[derive(Clone, Debug, Default)]
pub struct MouseClickEvent {
@@ -482,6 +503,7 @@ impl InputEvent for MouseExitEvent {
PlatformInput::MouseExited(self)
}
}
impl MouseEvent for MouseExitEvent {}
impl Deref for MouseExitEvent {