core: Add click index to ClipEvent::Press
This commit is contained in:
parent
a5a9ef9a03
commit
9188005820
|
@ -476,7 +476,7 @@ impl<'gc> TInteractiveObject<'gc> for Avm1Button<'gc> {
|
||||||
Some(ButtonActionCondition::OUT_DOWN_TO_OVER_DOWN),
|
Some(ButtonActionCondition::OUT_DOWN_TO_OVER_DOWN),
|
||||||
None,
|
None,
|
||||||
),
|
),
|
||||||
ClipEvent::Press => (
|
ClipEvent::Press { .. } => (
|
||||||
ButtonState::Down,
|
ButtonState::Down,
|
||||||
Some(ButtonActionCondition::OVER_UP_TO_OVER_DOWN),
|
Some(ButtonActionCondition::OVER_UP_TO_OVER_DOWN),
|
||||||
static_data.over_to_down_sound.as_ref(),
|
static_data.over_to_down_sound.as_ref(),
|
||||||
|
|
|
@ -752,7 +752,7 @@ impl<'gc> TInteractiveObject<'gc> for Avm2Button<'gc> {
|
||||||
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()),
|
||||||
ClipEvent::MouseUpInside => (ButtonState::Up, static_data.over_to_up_sound.as_ref()),
|
ClipEvent::MouseUpInside => (ButtonState::Up, static_data.over_to_up_sound.as_ref()),
|
||||||
|
|
|
@ -2410,7 +2410,7 @@ impl<'gc> TInteractiveObject<'gc> for EditText<'gc> {
|
||||||
event: ClipEvent,
|
event: ClipEvent,
|
||||||
) -> ClipEventResult {
|
) -> ClipEventResult {
|
||||||
match event {
|
match event {
|
||||||
ClipEvent::Press | ClipEvent::MouseWheel { .. } | ClipEvent::MouseMove => {
|
ClipEvent::Press { .. } | ClipEvent::MouseWheel { .. } | ClipEvent::MouseMove => {
|
||||||
ClipEventResult::Handled
|
ClipEventResult::Handled
|
||||||
}
|
}
|
||||||
_ => ClipEventResult::NotHandled,
|
_ => ClipEventResult::NotHandled,
|
||||||
|
@ -2437,7 +2437,7 @@ impl<'gc> TInteractiveObject<'gc> for EditText<'gc> {
|
||||||
return ClipEventResult::Handled;
|
return ClipEventResult::Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let ClipEvent::Press = event {
|
if let ClipEvent::Press { .. } = event {
|
||||||
if self.is_editable() || self.is_selectable() {
|
if self.is_editable() || self.is_selectable() {
|
||||||
let tracker = context.focus_tracker;
|
let tracker = context.focus_tracker;
|
||||||
tracker.set(Some(self.into()), context);
|
tracker.set(Some(self.into()), context);
|
||||||
|
|
|
@ -281,7 +281,7 @@ pub trait TInteractiveObject<'gc>:
|
||||||
let mut activation = Avm2Activation::from_nothing(context.reborrow());
|
let mut activation = Avm2Activation::from_nothing(context.reborrow());
|
||||||
|
|
||||||
match event {
|
match event {
|
||||||
ClipEvent::Press => {
|
ClipEvent::Press { .. } => {
|
||||||
let avm2_event = Avm2EventObject::mouse_event(
|
let avm2_event = Avm2EventObject::mouse_event(
|
||||||
&mut activation,
|
&mut activation,
|
||||||
"mouseDown",
|
"mouseDown",
|
||||||
|
|
|
@ -3000,7 +3000,9 @@ impl<'gc> TInteractiveObject<'gc> for MovieClip<'gc> {
|
||||||
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,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -176,7 +176,13 @@ pub enum ClipEvent<'gc> {
|
||||||
/// This is a targeted equivalent to `MouseDown` and is available in both
|
/// This is a targeted equivalent to `MouseDown` and is available in both
|
||||||
/// AVM1 and AVM2. The target of this event is determined by the position
|
/// AVM1 and AVM2. The target of this event is determined by the position
|
||||||
/// of the mouse cursor.
|
/// of the mouse cursor.
|
||||||
Press,
|
Press {
|
||||||
|
/// The index of this click in a click sequence performed in a quick succession.
|
||||||
|
///
|
||||||
|
/// For instance the value of 0 indicates it's a single click,
|
||||||
|
/// the number of 1 indicates it's a double click, etc.
|
||||||
|
index: usize,
|
||||||
|
},
|
||||||
|
|
||||||
/// Mouse moved out of a display object.
|
/// Mouse moved out of a display object.
|
||||||
///
|
///
|
||||||
|
@ -267,7 +273,7 @@ impl<'gc> ClipEvent<'gc> {
|
||||||
ClipEvent::MouseDown => Some(ClipEventFlag::MOUSE_DOWN),
|
ClipEvent::MouseDown => Some(ClipEventFlag::MOUSE_DOWN),
|
||||||
ClipEvent::MouseMove => Some(ClipEventFlag::MOUSE_MOVE),
|
ClipEvent::MouseMove => Some(ClipEventFlag::MOUSE_MOVE),
|
||||||
ClipEvent::MouseUp => Some(ClipEventFlag::MOUSE_UP),
|
ClipEvent::MouseUp => Some(ClipEventFlag::MOUSE_UP),
|
||||||
ClipEvent::Press => Some(ClipEventFlag::PRESS),
|
ClipEvent::Press { .. } => Some(ClipEventFlag::PRESS),
|
||||||
ClipEvent::RollOut { .. } => Some(ClipEventFlag::ROLL_OUT),
|
ClipEvent::RollOut { .. } => Some(ClipEventFlag::ROLL_OUT),
|
||||||
ClipEvent::RollOver { .. } => Some(ClipEventFlag::ROLL_OVER),
|
ClipEvent::RollOver { .. } => Some(ClipEventFlag::ROLL_OVER),
|
||||||
ClipEvent::Release => Some(ClipEventFlag::RELEASE),
|
ClipEvent::Release => Some(ClipEventFlag::RELEASE),
|
||||||
|
@ -326,7 +332,7 @@ impl<'gc> ClipEvent<'gc> {
|
||||||
ClipEvent::MouseDown => Some("onMouseDown"),
|
ClipEvent::MouseDown => Some("onMouseDown"),
|
||||||
ClipEvent::MouseMove => Some("onMouseMove"),
|
ClipEvent::MouseMove => Some("onMouseMove"),
|
||||||
ClipEvent::MouseUp => Some("onMouseUp"),
|
ClipEvent::MouseUp => Some("onMouseUp"),
|
||||||
ClipEvent::Press => Some("onPress"),
|
ClipEvent::Press { .. } => Some("onPress"),
|
||||||
ClipEvent::RollOut { .. } => Some("onRollOut"),
|
ClipEvent::RollOut { .. } => Some("onRollOut"),
|
||||||
ClipEvent::RollOver { .. } => Some("onRollOver"),
|
ClipEvent::RollOver { .. } => Some("onRollOver"),
|
||||||
ClipEvent::Release => Some("onRelease"),
|
ClipEvent::Release => Some("onRelease"),
|
||||||
|
|
|
@ -1153,7 +1153,7 @@ impl Player {
|
||||||
) {
|
) {
|
||||||
// The button/clip is pressed and then immediately released.
|
// The button/clip is pressed and then immediately released.
|
||||||
// We do not have to wait for KeyUp.
|
// We do not have to wait for KeyUp.
|
||||||
focus.handle_clip_event(context, ClipEvent::Press);
|
focus.handle_clip_event(context, ClipEvent::Press { index: 0 });
|
||||||
focus.handle_clip_event(context, ClipEvent::Release);
|
focus.handle_clip_event(context, ClipEvent::Release);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1478,10 +1478,10 @@ impl Player {
|
||||||
if context.input.is_mouse_down() {
|
if context.input.is_mouse_down() {
|
||||||
// Pressed on a hovered object.
|
// Pressed on a hovered object.
|
||||||
if let Some(over_object) = context.mouse_data.hovered {
|
if let Some(over_object) = context.mouse_data.hovered {
|
||||||
events.push((over_object, ClipEvent::Press));
|
events.push((over_object, ClipEvent::Press { index: 0 }));
|
||||||
context.mouse_data.pressed = context.mouse_data.hovered;
|
context.mouse_data.pressed = context.mouse_data.hovered;
|
||||||
} else {
|
} else {
|
||||||
events.push((context.stage.into(), ClipEvent::Press));
|
events.push((context.stage.into(), ClipEvent::Press { index: 0 }));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if let Some(over_object) = context.mouse_data.hovered {
|
if let Some(over_object) = context.mouse_data.hovered {
|
||||||
|
@ -1548,7 +1548,7 @@ impl Player {
|
||||||
if display_object.movie().is_action_script_3() {
|
if display_object.movie().is_action_script_3() {
|
||||||
object.event_dispatch_to_avm2(context, event);
|
object.event_dispatch_to_avm2(context, event);
|
||||||
}
|
}
|
||||||
if event == ClipEvent::Press {
|
if matches!(event, ClipEvent::Press { .. }) {
|
||||||
Self::update_focus_on_mouse_press(context, display_object);
|
Self::update_focus_on_mouse_press(context, display_object);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue