core: Don't make a object for the item menu callback, and set default to Undefined

This commit is contained in:
michiel2005 2024-08-09 14:42:32 +02:00
parent 117df6e3c2
commit d1f4445005
5 changed files with 15 additions and 6 deletions

View File

@ -20,7 +20,7 @@ pub fn constructor<'gc>(
.get(0)
.unwrap_or(&Value::Undefined)
.coerce_to_string(activation)?;
let callback = args.get(1).map(|v| v.coerce_to_object(activation));
let callback = *args.get(1).unwrap_or(&Value::Undefined);
let separator_before = args
.get(2)
.unwrap_or(&false.into())
@ -35,11 +35,7 @@ pub fn constructor<'gc>(
.as_bool(activation.swf_version());
this.set("caption", caption.into(), activation)?;
if let Some(callback) = callback {
this.set("onSelect", callback.into(), activation)?;
}
this.set("onSelect", callback, activation)?;
this.set("separatorBefore", separator_before.into(), activation)?;
this.set("enabled", enabled.into(), activation)?;
this.set("visible", visible.into(), activation)?;

View File

@ -0,0 +1,12 @@
undefined
undefined
[type Function]
undefined
[type Function]
true
true
true
true
true
ok
ok

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1 @@
num_frames = 1