avm2: Implement `TextField.alwaysShowSelection`

This commit is contained in:
Kamil Jarosz 2024-07-18 14:19:55 +02:00 committed by Nathan Adams
parent 842f310fe7
commit a6d321e1de
1 changed files with 22 additions and 7 deletions

View File

@ -53,20 +53,35 @@ pub fn text_field_allocator<'gc>(
} }
pub fn get_always_show_selection<'gc>( pub fn get_always_show_selection<'gc>(
activation: &mut Activation<'_, 'gc>, _activation: &mut Activation<'_, 'gc>,
_this: Object<'gc>, this: Object<'gc>,
_args: &[Value<'gc>], _args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> { ) -> Result<Value<'gc>, Error<'gc>> {
avm2_stub_getter!(activation, "flash.text.TextField", "alwaysShowSelection"); let Some(this) = this
Ok(Value::Bool(false)) .as_display_object()
.and_then(|this| this.as_edit_text())
else {
return Ok(Value::Undefined);
};
Ok(this.always_show_selection().into())
} }
pub fn set_always_show_selection<'gc>( pub fn set_always_show_selection<'gc>(
activation: &mut Activation<'_, 'gc>, activation: &mut Activation<'_, 'gc>,
_this: Object<'gc>, this: Object<'gc>,
_args: &[Value<'gc>], args: &[Value<'gc>],
) -> Result<Value<'gc>, Error<'gc>> { ) -> Result<Value<'gc>, Error<'gc>> {
avm2_stub_setter!(activation, "flash.text.TextField", "alwaysShowSelection"); let Some(this) = this
.as_display_object()
.and_then(|this| this.as_edit_text())
else {
return Ok(Value::Undefined);
};
let value = args.get_bool(0);
this.set_always_show_selection(&mut activation.context, value);
Ok(Value::Undefined) Ok(Value::Undefined)
} }