diff --git a/core/src/display_object/button.rs b/core/src/display_object/button.rs index 54278bf50..0c079155f 100644 --- a/core/src/display_object/button.rs +++ b/core/src/display_object/button.rs @@ -280,13 +280,7 @@ impl<'gc> TDisplayObject<'gc> for Button<'gc> { } fn hit_test_bounds(&self, point: (Twips, Twips)) -> bool { - for child in self.0.read().hit_area.values().rev() { - if child.world_bounds().contains(point) { - return true; - } - } - - false + self.world_bounds().contains(point) } fn hit_test_shape(&self, point: (Twips, Twips)) -> bool { @@ -306,11 +300,14 @@ impl<'gc> TDisplayObject<'gc> for Button<'gc> { point: (Twips, Twips), ) -> Option> { // The button is hovered if the mouse is over any child nodes. - if self.hit_test_bounds(point) { - Some(self_node) - } else { - None + if self.visible() { + for child in self.0.read().hit_area.values() { + if child.hit_test_shape(point) { + return Some(self_node); + } + } } + None } fn object(&self) -> Value<'gc> { diff --git a/core/src/display_object/movie_clip.rs b/core/src/display_object/movie_clip.rs index 61229f218..b2c8ac265 100644 --- a/core/src/display_object/movie_clip.rs +++ b/core/src/display_object/movie_clip.rs @@ -1086,24 +1086,27 @@ impl<'gc> TDisplayObject<'gc> for MovieClip<'gc> { self_node: DisplayObject<'gc>, point: (Twips, Twips), ) -> Option> { - if self.visible() { - if self.world_bounds().contains(point) { + if self.visible() && self.world_bounds().contains(point) { + // This movieclip operates in "button mode" if it has a mouse handler, + // either via on(..) or via property mc.onRelease, etc. + let is_button_mode = { if self.0.read().has_button_clip_event { - return Some(self_node); - } + true + } else { + let mut activation = Activation::from_stub( + context.reborrow(), + ActivationIdentifier::root("[Mouse Pick]"), + ); + let object = self.object().coerce_to_object(&mut activation); - let mut activation = Activation::from_stub( - context.reborrow(), - ActivationIdentifier::root("[Mouse Pick]"), - ); - let object = self.object().coerce_to_object(&mut activation); - - if ClipEvent::BUTTON_EVENT_METHODS - .iter() - .any(|handler| object.has_property(&mut activation, handler)) - { - return Some(self_node); + ClipEvent::BUTTON_EVENT_METHODS + .iter() + .any(|handler| object.has_property(&mut activation, handler)) } + }; + + if is_button_mode && self.hit_test_shape(point) { + return Some(self_node); } // Maybe we could skip recursing down at all if !world_bounds.contains(point),