core: Update focus highlight reset logic for SWF9+

SWF versions 9 onwards reset the highlight only on
left mouse button down, whereas older versions also
reset it on other mouse events.
This commit is contained in:
Kamil Jarosz 2024-04-22 21:17:47 +02:00 committed by Nathan Adams
parent 4ec30928ab
commit 953a741943
1 changed files with 32 additions and 6 deletions

View File

@ -1193,18 +1193,44 @@ impl Player {
});
}
if matches!(
event,
PlayerEvent::MouseDown { .. }
| PlayerEvent::MouseUp { .. }
| PlayerEvent::MouseMove { .. }
) {
if self.should_reset_highlight(event) {
self.mutate_with_update_context(|context| {
context.focus_tracker.reset_highlight();
});
}
}
fn should_reset_highlight(&self, event: PlayerEvent) -> bool {
if matches!(
event,
PlayerEvent::MouseDown {
button: MouseButton::Left,
..
}
) {
// Left mouse button down always resets the highlight.
return true;
}
if self.swf.version() < 9
&& matches!(
event,
PlayerEvent::MouseDown {
button: MouseButton::Left | MouseButton::Right,
..
} | PlayerEvent::MouseUp {
button: MouseButton::Left | MouseButton::Right,
..
} | PlayerEvent::MouseMove { .. }
)
{
// For SWF8 and older, other mouse events also reset the highlight.
return true;
}
false
}
/// Update dragged object, if any.
pub fn update_drag(context: &mut UpdateContext<'_, '_>) {
let mouse_position = *context.mouse_position;