diff --git a/core/src/display_object/avm1_button.rs b/core/src/display_object/avm1_button.rs index 6ec9ccb7b..d9611a996 100644 --- a/core/src/display_object/avm1_button.rs +++ b/core/src/display_object/avm1_button.rs @@ -476,7 +476,7 @@ impl<'gc> TInteractiveObject<'gc> for Avm1Button<'gc> { Some(ButtonActionCondition::OUT_DOWN_TO_OVER_DOWN), None, ), - ClipEvent::Press => ( + ClipEvent::Press { .. } => ( ButtonState::Down, Some(ButtonActionCondition::OVER_UP_TO_OVER_DOWN), static_data.over_to_down_sound.as_ref(), diff --git a/core/src/display_object/avm2_button.rs b/core/src/display_object/avm2_button.rs index b4f4ff4e7..a2e94c733 100644 --- a/core/src/display_object/avm2_button.rs +++ b/core/src/display_object/avm2_button.rs @@ -752,7 +752,7 @@ impl<'gc> TInteractiveObject<'gc> for Avm2Button<'gc> { let (new_state, sound) = match event { ClipEvent::DragOut { .. } => (ButtonState::Over, 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::ReleaseOutside => (ButtonState::Up, static_data.over_to_up_sound.as_ref()), ClipEvent::MouseUpInside => (ButtonState::Up, static_data.over_to_up_sound.as_ref()), diff --git a/core/src/display_object/edit_text.rs b/core/src/display_object/edit_text.rs index 259f18742..2234eaf1f 100644 --- a/core/src/display_object/edit_text.rs +++ b/core/src/display_object/edit_text.rs @@ -2410,7 +2410,7 @@ impl<'gc> TInteractiveObject<'gc> for EditText<'gc> { event: ClipEvent, ) -> ClipEventResult { match event { - ClipEvent::Press | ClipEvent::MouseWheel { .. } | ClipEvent::MouseMove => { + ClipEvent::Press { .. } | ClipEvent::MouseWheel { .. } | ClipEvent::MouseMove => { ClipEventResult::Handled } _ => ClipEventResult::NotHandled, @@ -2437,7 +2437,7 @@ impl<'gc> TInteractiveObject<'gc> for EditText<'gc> { return ClipEventResult::Handled; } - if let ClipEvent::Press = event { + if let ClipEvent::Press { .. } = event { if self.is_editable() || self.is_selectable() { let tracker = context.focus_tracker; tracker.set(Some(self.into()), context); diff --git a/core/src/display_object/interactive.rs b/core/src/display_object/interactive.rs index 5107795f1..385115fd1 100644 --- a/core/src/display_object/interactive.rs +++ b/core/src/display_object/interactive.rs @@ -281,7 +281,7 @@ pub trait TInteractiveObject<'gc>: let mut activation = Avm2Activation::from_nothing(context.reborrow()); match event { - ClipEvent::Press => { + ClipEvent::Press { .. } => { let avm2_event = Avm2EventObject::mouse_event( &mut activation, "mouseDown", diff --git a/core/src/display_object/movie_clip.rs b/core/src/display_object/movie_clip.rs index c26453414..f95bf816f 100644 --- a/core/src/display_object/movie_clip.rs +++ b/core/src/display_object/movie_clip.rs @@ -3000,7 +3000,9 @@ impl<'gc> TInteractiveObject<'gc> for MovieClip<'gc> { 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 0d6191044..ed8c309a4 100644 --- a/core/src/events.rs +++ b/core/src/events.rs @@ -176,7 +176,13 @@ pub enum ClipEvent<'gc> { /// 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 /// 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. /// @@ -267,7 +273,7 @@ impl<'gc> ClipEvent<'gc> { ClipEvent::MouseDown => Some(ClipEventFlag::MOUSE_DOWN), ClipEvent::MouseMove => Some(ClipEventFlag::MOUSE_MOVE), ClipEvent::MouseUp => Some(ClipEventFlag::MOUSE_UP), - ClipEvent::Press => Some(ClipEventFlag::PRESS), + ClipEvent::Press { .. } => Some(ClipEventFlag::PRESS), ClipEvent::RollOut { .. } => Some(ClipEventFlag::ROLL_OUT), ClipEvent::RollOver { .. } => Some(ClipEventFlag::ROLL_OVER), ClipEvent::Release => Some(ClipEventFlag::RELEASE), @@ -326,7 +332,7 @@ impl<'gc> ClipEvent<'gc> { ClipEvent::MouseDown => Some("onMouseDown"), ClipEvent::MouseMove => Some("onMouseMove"), ClipEvent::MouseUp => Some("onMouseUp"), - ClipEvent::Press => Some("onPress"), + ClipEvent::Press { .. } => Some("onPress"), ClipEvent::RollOut { .. } => Some("onRollOut"), ClipEvent::RollOver { .. } => Some("onRollOver"), ClipEvent::Release => Some("onRelease"), diff --git a/core/src/player.rs b/core/src/player.rs index e67e7c391..79462134a 100644 --- a/core/src/player.rs +++ b/core/src/player.rs @@ -1153,7 +1153,7 @@ impl Player { ) { // The button/clip is pressed and then immediately released. // 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); } } @@ -1478,10 +1478,10 @@ impl Player { if context.input.is_mouse_down() { // Pressed on a hovered object. 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; } else { - events.push((context.stage.into(), ClipEvent::Press)); + events.push((context.stage.into(), ClipEvent::Press { index: 0 })); } } else { if let Some(over_object) = context.mouse_data.hovered { @@ -1548,7 +1548,7 @@ impl Player { if display_object.movie().is_action_script_3() { 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); } }