|
1 |
| -use crate::{display_object::InteractiveObject, input::InputEvent}; |
| 1 | +use crate::display_object::InteractiveObject; |
| 2 | +use crate::input::InputEvent; |
| 3 | +use crate::string::{AvmString, StringContext}; |
| 4 | +use ruffle_macros::istr; |
2 | 5 | use std::str::FromStr;
|
3 | 6 | use swf::ClipEventFlag;
|
4 | 7 |
|
@@ -391,27 +394,27 @@ impl ClipEvent<'_> {
|
391 | 394 | /// `ClipEvent::Data` returns `None` rather than `onData` because its behavior
|
392 | 395 | /// differs from the other events: the method must fire before the SWF-defined
|
393 | 396 | /// event handler, so we'll explicitly call `onData` in the appropriate places.
|
394 |
| - pub const fn method_name(self) -> Option<&'static str> { |
| 397 | + pub fn method_name<'gc>(self, ctx: &StringContext<'gc>) -> Option<AvmString<'gc>> { |
395 | 398 | match self {
|
396 | 399 | ClipEvent::Construct => None,
|
397 | 400 | ClipEvent::Data => None,
|
398 |
| - ClipEvent::DragOut { .. } => Some("onDragOut"), |
399 |
| - ClipEvent::DragOver { .. } => Some("onDragOver"), |
400 |
| - ClipEvent::EnterFrame => Some("onEnterFrame"), |
| 401 | + ClipEvent::DragOut { .. } => Some(istr!(ctx, "onDragOut")), |
| 402 | + ClipEvent::DragOver { .. } => Some(istr!(ctx, "onDragOver")), |
| 403 | + ClipEvent::EnterFrame => Some(istr!(ctx, "onEnterFrame")), |
401 | 404 | ClipEvent::Initialize => None,
|
402 |
| - ClipEvent::KeyDown => Some("onKeyDown"), |
| 405 | + ClipEvent::KeyDown => Some(istr!(ctx, "onKeyDown")), |
403 | 406 | ClipEvent::KeyPress { .. } => None,
|
404 |
| - ClipEvent::KeyUp => Some("onKeyUp"), |
405 |
| - ClipEvent::Load => Some("onLoad"), |
406 |
| - ClipEvent::MouseDown => Some("onMouseDown"), |
407 |
| - ClipEvent::MouseMove => Some("onMouseMove"), |
408 |
| - ClipEvent::MouseUp => Some("onMouseUp"), |
409 |
| - ClipEvent::Press { .. } => Some("onPress"), |
410 |
| - ClipEvent::RollOut { .. } => Some("onRollOut"), |
411 |
| - ClipEvent::RollOver { .. } => Some("onRollOver"), |
412 |
| - ClipEvent::Release { .. } => Some("onRelease"), |
413 |
| - ClipEvent::ReleaseOutside => Some("onReleaseOutside"), |
414 |
| - ClipEvent::Unload => Some("onUnload"), |
| 407 | + ClipEvent::KeyUp => Some(istr!(ctx, "onKeyUp")), |
| 408 | + ClipEvent::Load => Some(istr!(ctx, "onLoad")), |
| 409 | + ClipEvent::MouseDown => Some(istr!(ctx, "onMouseDown")), |
| 410 | + ClipEvent::MouseMove => Some(istr!(ctx, "onMouseMove")), |
| 411 | + ClipEvent::MouseUp => Some(istr!(ctx, "onMouseUp")), |
| 412 | + ClipEvent::Press { .. } => Some(istr!(ctx, "onPress")), |
| 413 | + ClipEvent::RollOut { .. } => Some(istr!(ctx, "onRollOut")), |
| 414 | + ClipEvent::RollOver { .. } => Some(istr!(ctx, "onRollOver")), |
| 415 | + ClipEvent::Release { .. } => Some(istr!(ctx, "onRelease")), |
| 416 | + ClipEvent::ReleaseOutside => Some(istr!(ctx, "onReleaseOutside")), |
| 417 | + ClipEvent::Unload => Some(istr!(ctx, "onUnload")), |
415 | 418 | _ => None,
|
416 | 419 | }
|
417 | 420 | }
|
|
0 commit comments