diff --git a/core/src/display_object/avm1_button.rs b/core/src/display_object/avm1_button.rs index 9c1ec7fbe..e98bb34b1 100644 --- a/core/src/display_object/avm1_button.rs +++ b/core/src/display_object/avm1_button.rs @@ -446,12 +446,12 @@ impl<'gc> TInteractiveObject<'gc> for Avm1Button<'gc> { let static_data = write.static_data; let static_data = static_data.read(); let (new_state, condition, sound) = match event { - ClipEvent::DragOut => ( + ClipEvent::DragOut { .. } => ( ButtonState::Over, ButtonActionCondition::OVER_DOWN_TO_OUT_DOWN, None, ), - ClipEvent::DragOver => ( + ClipEvent::DragOver { .. } => ( ButtonState::Down, ButtonActionCondition::OUT_DOWN_TO_OVER_DOWN, None, diff --git a/core/src/display_object/avm2_button.rs b/core/src/display_object/avm2_button.rs index 3a6fd3aeb..ba9bcdcbf 100644 --- a/core/src/display_object/avm2_button.rs +++ b/core/src/display_object/avm2_button.rs @@ -749,8 +749,8 @@ impl<'gc> TInteractiveObject<'gc> for Avm2Button<'gc> { let static_data = write.static_data; let static_data = static_data.read(); let (new_state, sound) = match event { - ClipEvent::DragOut => (ButtonState::Over, None), - ClipEvent::DragOver => (ButtonState::Down, None), + ClipEvent::DragOut { .. } => (ButtonState::Over, None), + ClipEvent::DragOver { .. } => (ButtonState::Down, None), ClipEvent::Press => (ButtonState::Down, static_data.over_to_down_sound.as_ref()), ClipEvent::Release => (ButtonState::Over, static_data.down_to_over_sound.as_ref()), ClipEvent::ReleaseOutside => (ButtonState::Up, static_data.over_to_up_sound.as_ref()), diff --git a/core/src/display_object/interactive.rs b/core/src/display_object/interactive.rs index 1918de5d0..05f056429 100644 --- a/core/src/display_object/interactive.rs +++ b/core/src/display_object/interactive.rs @@ -264,7 +264,7 @@ pub trait TInteractiveObject<'gc>: ClipEventResult::Handled } - ClipEvent::RollOut { to } => { + ClipEvent::RollOut { to } | ClipEvent::DragOut { to } => { let mut avm2_event = Avm2Event::new( "mouseOut", Avm2EventData::mouse_event(context, self.as_displayobject(), to, 0), @@ -302,7 +302,7 @@ pub trait TInteractiveObject<'gc>: ClipEventResult::Handled } - ClipEvent::RollOver { from } => { + ClipEvent::RollOver { from } | ClipEvent::DragOver { from } => { let lca = lowest_common_ancestor( self.as_displayobject(), from.map(|t| t.as_displayobject()) diff --git a/core/src/display_object/movie_clip.rs b/core/src/display_object/movie_clip.rs index 32af74afc..b05d79904 100644 --- a/core/src/display_object/movie_clip.rs +++ b/core/src/display_object/movie_clip.rs @@ -2064,10 +2064,10 @@ impl<'gc> TInteractiveObject<'gc> for MovieClip<'gc> { ) -> ClipEventResult { let frame_name = match event { ClipEvent::RollOut { .. } | ClipEvent::ReleaseOutside => Some(WStr::from_units(b"_up")), - ClipEvent::RollOver { .. } | ClipEvent::Release | ClipEvent::DragOut => { + ClipEvent::RollOver { .. } | ClipEvent::Release | ClipEvent::DragOut { .. } => { Some(WStr::from_units(b"_over")) } - ClipEvent::Press | ClipEvent::DragOver => Some(WStr::from_units(b"_down")), + ClipEvent::Press | ClipEvent::DragOver { .. } => Some(WStr::from_units(b"_down")), _ => None, }; diff --git a/core/src/events.rs b/core/src/events.rs index d2d0b2ec3..5dcefd207 100644 --- a/core/src/events.rs +++ b/core/src/events.rs @@ -77,8 +77,27 @@ pub enum ClipEventResult { pub enum ClipEvent<'gc> { Construct, Data, - DragOut, - DragOver, + + /// Mouse moved out of a display object while the primary button is held + /// down. + /// + /// This is a targeted equivalent to `MouseMove` and is available in both + /// AVM1 and AVM2. In AVM2, it is dispatched identically to `RollOut`, with + /// the only difference being that the `buttonDown` flag is set to true. + DragOut { + to: Option>, + }, + + /// Mouse moved into of a display object while the primary button is held + /// down. + /// + /// This is a targeted equivalent to `MouseMove` and is available in both + /// AVM1 and AVM2. In AVM2, it is dispatched identically to `RollOver`, + /// with the only difference being that the `buttonDown` flag is set to + /// true. + DragOver { + from: Option>, + }, EnterFrame, Initialize, KeyUp, @@ -182,8 +201,8 @@ impl<'gc> ClipEvent<'gc> { match self { ClipEvent::Construct => ClipEventFlag::CONSTRUCT, ClipEvent::Data => ClipEventFlag::DATA, - ClipEvent::DragOut => ClipEventFlag::DRAG_OUT, - ClipEvent::DragOver => ClipEventFlag::DRAG_OVER, + ClipEvent::DragOut { .. } => ClipEventFlag::DRAG_OUT, + ClipEvent::DragOver { .. } => ClipEventFlag::DRAG_OVER, ClipEvent::EnterFrame => ClipEventFlag::ENTER_FRAME, ClipEvent::Initialize => ClipEventFlag::INITIALIZE, ClipEvent::KeyDown => ClipEventFlag::KEY_DOWN, @@ -230,8 +249,8 @@ impl<'gc> ClipEvent<'gc> { match self { ClipEvent::Construct => None, ClipEvent::Data => Some("onData"), - ClipEvent::DragOut => Some("onDragOut"), - ClipEvent::DragOver => Some("onDragOver"), + ClipEvent::DragOut { .. } => Some("onDragOut"), + ClipEvent::DragOver { .. } => Some("onDragOver"), ClipEvent::EnterFrame => Some("onEnterFrame"), ClipEvent::Initialize => None, ClipEvent::KeyDown => Some("onKeyDown"), diff --git a/core/src/player.rs b/core/src/player.rs index 7e51d53ec..b2f027cc9 100644 --- a/core/src/player.rs +++ b/core/src/player.rs @@ -1145,13 +1145,23 @@ impl Player { cur_over_object, ) { // Dragged from outside the clicked object to the inside. - events.push((down_object, ClipEvent::DragOut)); + events.push(( + down_object, + ClipEvent::DragOut { + to: new_over_object, + }, + )); } else if InteractiveObject::option_ptr_eq( context.mouse_down_object, new_over_object, ) { // Dragged from inside the clicked object to the outside. - events.push((down_object, ClipEvent::DragOver)); + events.push(( + down_object, + ClipEvent::DragOver { + from: cur_over_object, + }, + )); } } } else {