core: Issue `mouseOver`, `mouseOut`, etc when dragging.
This commit is contained in:
parent
42b606d058
commit
84d1d5aa76
|
@ -446,12 +446,12 @@ impl<'gc> TInteractiveObject<'gc> for Avm1Button<'gc> {
|
||||||
let static_data = write.static_data;
|
let static_data = write.static_data;
|
||||||
let static_data = static_data.read();
|
let static_data = static_data.read();
|
||||||
let (new_state, condition, sound) = match event {
|
let (new_state, condition, sound) = match event {
|
||||||
ClipEvent::DragOut => (
|
ClipEvent::DragOut { .. } => (
|
||||||
ButtonState::Over,
|
ButtonState::Over,
|
||||||
ButtonActionCondition::OVER_DOWN_TO_OUT_DOWN,
|
ButtonActionCondition::OVER_DOWN_TO_OUT_DOWN,
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
ClipEvent::DragOver => (
|
ClipEvent::DragOver { .. } => (
|
||||||
ButtonState::Down,
|
ButtonState::Down,
|
||||||
ButtonActionCondition::OUT_DOWN_TO_OVER_DOWN,
|
ButtonActionCondition::OUT_DOWN_TO_OVER_DOWN,
|
||||||
None,
|
None,
|
||||||
|
|
|
@ -749,8 +749,8 @@ impl<'gc> TInteractiveObject<'gc> for Avm2Button<'gc> {
|
||||||
let static_data = write.static_data;
|
let static_data = write.static_data;
|
||||||
let static_data = static_data.read();
|
let static_data = static_data.read();
|
||||||
let (new_state, sound) = match event {
|
let (new_state, sound) = match event {
|
||||||
ClipEvent::DragOut => (ButtonState::Over, None),
|
ClipEvent::DragOut { .. } => (ButtonState::Over, None),
|
||||||
ClipEvent::DragOver => (ButtonState::Down, None),
|
ClipEvent::DragOver { .. } => (ButtonState::Down, None),
|
||||||
ClipEvent::Press => (ButtonState::Down, static_data.over_to_down_sound.as_ref()),
|
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::Release => (ButtonState::Over, static_data.down_to_over_sound.as_ref()),
|
||||||
ClipEvent::ReleaseOutside => (ButtonState::Up, static_data.over_to_up_sound.as_ref()),
|
ClipEvent::ReleaseOutside => (ButtonState::Up, static_data.over_to_up_sound.as_ref()),
|
||||||
|
|
|
@ -264,7 +264,7 @@ pub trait TInteractiveObject<'gc>:
|
||||||
|
|
||||||
ClipEventResult::Handled
|
ClipEventResult::Handled
|
||||||
}
|
}
|
||||||
ClipEvent::RollOut { to } => {
|
ClipEvent::RollOut { to } | ClipEvent::DragOut { to } => {
|
||||||
let mut avm2_event = Avm2Event::new(
|
let mut avm2_event = Avm2Event::new(
|
||||||
"mouseOut",
|
"mouseOut",
|
||||||
Avm2EventData::mouse_event(context, self.as_displayobject(), to, 0),
|
Avm2EventData::mouse_event(context, self.as_displayobject(), to, 0),
|
||||||
|
@ -302,7 +302,7 @@ pub trait TInteractiveObject<'gc>:
|
||||||
|
|
||||||
ClipEventResult::Handled
|
ClipEventResult::Handled
|
||||||
}
|
}
|
||||||
ClipEvent::RollOver { from } => {
|
ClipEvent::RollOver { from } | ClipEvent::DragOver { from } => {
|
||||||
let lca = lowest_common_ancestor(
|
let lca = lowest_common_ancestor(
|
||||||
self.as_displayobject(),
|
self.as_displayobject(),
|
||||||
from.map(|t| t.as_displayobject())
|
from.map(|t| t.as_displayobject())
|
||||||
|
|
|
@ -2064,10 +2064,10 @@ impl<'gc> TInteractiveObject<'gc> for MovieClip<'gc> {
|
||||||
) -> ClipEventResult {
|
) -> ClipEventResult {
|
||||||
let frame_name = match event {
|
let frame_name = match event {
|
||||||
ClipEvent::RollOut { .. } | ClipEvent::ReleaseOutside => Some(WStr::from_units(b"_up")),
|
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"))
|
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,
|
_ => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -77,8 +77,27 @@ pub enum ClipEventResult {
|
||||||
pub enum ClipEvent<'gc> {
|
pub enum ClipEvent<'gc> {
|
||||||
Construct,
|
Construct,
|
||||||
Data,
|
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<InteractiveObject<'gc>>,
|
||||||
|
},
|
||||||
|
|
||||||
|
/// 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<InteractiveObject<'gc>>,
|
||||||
|
},
|
||||||
EnterFrame,
|
EnterFrame,
|
||||||
Initialize,
|
Initialize,
|
||||||
KeyUp,
|
KeyUp,
|
||||||
|
@ -182,8 +201,8 @@ impl<'gc> ClipEvent<'gc> {
|
||||||
match self {
|
match self {
|
||||||
ClipEvent::Construct => ClipEventFlag::CONSTRUCT,
|
ClipEvent::Construct => ClipEventFlag::CONSTRUCT,
|
||||||
ClipEvent::Data => ClipEventFlag::DATA,
|
ClipEvent::Data => ClipEventFlag::DATA,
|
||||||
ClipEvent::DragOut => ClipEventFlag::DRAG_OUT,
|
ClipEvent::DragOut { .. } => ClipEventFlag::DRAG_OUT,
|
||||||
ClipEvent::DragOver => ClipEventFlag::DRAG_OVER,
|
ClipEvent::DragOver { .. } => ClipEventFlag::DRAG_OVER,
|
||||||
ClipEvent::EnterFrame => ClipEventFlag::ENTER_FRAME,
|
ClipEvent::EnterFrame => ClipEventFlag::ENTER_FRAME,
|
||||||
ClipEvent::Initialize => ClipEventFlag::INITIALIZE,
|
ClipEvent::Initialize => ClipEventFlag::INITIALIZE,
|
||||||
ClipEvent::KeyDown => ClipEventFlag::KEY_DOWN,
|
ClipEvent::KeyDown => ClipEventFlag::KEY_DOWN,
|
||||||
|
@ -230,8 +249,8 @@ impl<'gc> ClipEvent<'gc> {
|
||||||
match self {
|
match self {
|
||||||
ClipEvent::Construct => None,
|
ClipEvent::Construct => None,
|
||||||
ClipEvent::Data => Some("onData"),
|
ClipEvent::Data => Some("onData"),
|
||||||
ClipEvent::DragOut => Some("onDragOut"),
|
ClipEvent::DragOut { .. } => Some("onDragOut"),
|
||||||
ClipEvent::DragOver => Some("onDragOver"),
|
ClipEvent::DragOver { .. } => Some("onDragOver"),
|
||||||
ClipEvent::EnterFrame => Some("onEnterFrame"),
|
ClipEvent::EnterFrame => Some("onEnterFrame"),
|
||||||
ClipEvent::Initialize => None,
|
ClipEvent::Initialize => None,
|
||||||
ClipEvent::KeyDown => Some("onKeyDown"),
|
ClipEvent::KeyDown => Some("onKeyDown"),
|
||||||
|
|
|
@ -1145,13 +1145,23 @@ impl Player {
|
||||||
cur_over_object,
|
cur_over_object,
|
||||||
) {
|
) {
|
||||||
// Dragged from outside the clicked object to the inside.
|
// 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(
|
} else if InteractiveObject::option_ptr_eq(
|
||||||
context.mouse_down_object,
|
context.mouse_down_object,
|
||||||
new_over_object,
|
new_over_object,
|
||||||
) {
|
) {
|
||||||
// Dragged from inside the clicked object to the outside.
|
// 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 {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue