avm2: Ensure the focus is dropped when it's removed
The logic of dropping the focus when it's removed applies not only to TextFields but for every InteractiveObject. This patch ensures that any focus is dropped when its parent is removed.
This commit is contained in:
parent
428688e7e7
commit
b551d14a59
|
@ -1594,6 +1594,10 @@ pub trait TDisplayObject<'gc>:
|
||||||
let parent_removed = had_parent && !has_parent;
|
let parent_removed = had_parent && !has_parent;
|
||||||
|
|
||||||
if parent_removed {
|
if parent_removed {
|
||||||
|
if let Some(int) = self.as_interactive() {
|
||||||
|
int.drop_focus(context);
|
||||||
|
}
|
||||||
|
|
||||||
self.on_parent_removed(context);
|
self.on_parent_removed(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2114,16 +2114,6 @@ impl<'gc> TDisplayObject<'gc> for EditText<'gc> {
|
||||||
self.0.write(context.gc_context).object = Some(to.into());
|
self.0.write(context.gc_context).object = Some(to.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_parent_removed(&self, context: &mut UpdateContext<'_, 'gc>) {
|
|
||||||
if self.movie().is_action_script_3() {
|
|
||||||
let had_focus = self.has_focus();
|
|
||||||
if had_focus {
|
|
||||||
let tracker = context.focus_tracker;
|
|
||||||
tracker.set(None, context);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn self_bounds(&self) -> Rectangle<Twips> {
|
fn self_bounds(&self) -> Rectangle<Twips> {
|
||||||
self.0.read().bounds.clone()
|
self.0.read().bounds.clone()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue