Skip to content

Commit

Permalink
avm1: added the onScroller listener
Browse files Browse the repository at this point in the history
  • Loading branch information
Flawake authored and torokati44 committed Mar 14, 2024
1 parent 7479c3b commit b6cd003
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions core/src/display_object/edit_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1785,6 +1785,18 @@ impl<'gc> EditText<'gc> {
}
}

fn on_scroller(&self, activation: &mut Avm1Activation<'_, 'gc>) {
if let Avm1Value::Object(object) = self.object() {
let _ = object.call_method(
"broadcastMessage".into(),
&["onScroller".into(), object.into()],
activation,
ExecutionReason::Special,
);
}
//TODO: Implement this for Avm2
}

/// Construct the text field's AVM1 representation.
fn construct_as_avm1_object(&self, context: &mut UpdateContext<'_, 'gc>, run_frame: bool) {
let mut text = self.0.write(context.gc_context);
Expand Down Expand Up @@ -2061,9 +2073,6 @@ impl<'gc> TDisplayObject<'gc> for EditText<'gc> {
context
.avm1
.add_to_exec_list(context.gc_context, (*self).into());
}

if !self.movie().is_action_script_3() {
self.construct_as_avm1_object(context, run_frame);
}
}
Expand Down Expand Up @@ -2339,6 +2348,13 @@ impl<'gc> TInteractiveObject<'gc> for EditText<'gc> {
if self.is_mouse_wheel_enabled() {
let new_scroll = self.scroll() as f64 - delta.lines();
self.set_scroll(new_scroll, context);

let mut activation = Avm1Activation::from_nothing(
context.reborrow(),
ActivationIdentifier::root("[On Scroller]"),
self.into(),
);
self.on_scroller(&mut activation);
}
return ClipEventResult::Handled;
}
Expand Down

0 comments on commit b6cd003

Please sign in to comment.