From aaede767fe3511de3af7948e4dd8c8fcd4dea2ec Mon Sep 17 00:00:00 2001 From: michiel2005 <60014996+michiel2005@users.noreply.github.com> Date: Fri, 2 Jun 2023 09:41:08 +0200 Subject: [PATCH] Made sure that the objects are actually in the same movie and added a bit of documentation --- core/src/player.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/core/src/player.rs b/core/src/player.rs index 0d309884a..bbafa1886 100644 --- a/core/src/player.rs +++ b/core/src/player.rs @@ -1285,6 +1285,7 @@ impl Player { display_object = Self::find_first_character_instance( root_clip, &down_object.as_displayobject().id(), + &down_object.as_displayobject().movie(), ); } @@ -1495,19 +1496,23 @@ impl Player { needs_render } - ///This searches for a display object by it's id - //TODO: is there a better place to place next two functions + ///This searches for a display object by it's id. + ///When a button is being held down but the mouse stops hovering over the object + ///we need to know if th button is still there after goto. + //TODO: is there a better place to place next two functions? fn find_first_character_instance<'gc>( obj: DisplayObject<'gc>, character_id: &CharacterId, + needed_movie: &Arc, ) -> Option> { if let Some(parent) = obj.as_container() { for child in parent.iter_render_list() { - if &child.id() == character_id && Arc::ptr_eq(&child.movie(), &obj.movie()) { + if &child.id() == character_id && Arc::ptr_eq(&child.movie(), needed_movie) { return Some(child); } - let display_object = Self::find_first_character_instance(child, character_id); + let display_object = + Self::find_first_character_instance(child, character_id, needed_movie); if display_object.is_some() { return display_object; }