core: Call focus handlers on every object

Before this patch, focus handlers were called from on_focus_changed,
only for selected objects. It seems that they should be called for
every object by default.
This commit is contained in:
Kamil Jarosz 2024-05-04 18:59:34 +02:00 committed by Lord-McSweeney
parent f5a0751557
commit 42c26f61d1
5 changed files with 8 additions and 12 deletions

View File

@ -610,12 +610,11 @@ impl<'gc> TInteractiveObject<'gc> for Avm1Button<'gc> {
fn on_focus_changed(
&self,
context: &mut UpdateContext<'_, 'gc>,
_context: &mut UpdateContext<'_, 'gc>,
focused: bool,
other: Option<InteractiveObject<'gc>>,
_other: Option<InteractiveObject<'gc>>,
) {
self.0.has_focus.set(focused);
self.call_focus_handler(context, focused, other);
}
fn tab_enabled_avm1(&self, context: &mut UpdateContext<'_, 'gc>) -> bool {

View File

@ -826,12 +826,11 @@ impl<'gc> TInteractiveObject<'gc> for Avm2Button<'gc> {
fn on_focus_changed(
&self,
context: &mut UpdateContext<'_, 'gc>,
_context: &mut UpdateContext<'_, 'gc>,
focused: bool,
other: Option<InteractiveObject<'gc>>,
_other: Option<InteractiveObject<'gc>>,
) {
self.0.has_focus.set(focused);
self.call_focus_handler(context, focused, other);
}
fn tab_enabled_avm2_default(&self, _context: &mut UpdateContext<'_, 'gc>) -> bool {

View File

@ -2457,7 +2457,7 @@ impl<'gc> TInteractiveObject<'gc> for EditText<'gc> {
&self,
context: &mut UpdateContext<'_, 'gc>,
focused: bool,
other: Option<InteractiveObject<'gc>>,
_other: Option<InteractiveObject<'gc>>,
) {
let is_action_script_3 = self.movie().is_action_script_3();
let mut text = self.0.write(context.gc_context);
@ -2465,9 +2465,6 @@ impl<'gc> TInteractiveObject<'gc> for EditText<'gc> {
if !focused && !is_action_script_3 {
text.selection = None;
}
drop(text);
self.call_focus_handler(context, focused, other);
}
fn is_highlightable(&self, _context: &mut UpdateContext<'_, 'gc>) -> bool {

View File

@ -3390,10 +3390,9 @@ impl<'gc> TInteractiveObject<'gc> for MovieClip<'gc> {
&self,
context: &mut UpdateContext<'_, 'gc>,
focused: bool,
other: Option<InteractiveObject<'gc>>,
_other: Option<InteractiveObject<'gc>>,
) {
self.0.write(context.gc_context).has_focus = focused;
self.call_focus_handler(context, focused, other);
}
fn tab_enabled_avm1(&self, context: &mut UpdateContext<'_, 'gc>) -> bool {

View File

@ -99,9 +99,11 @@ impl<'gc> FocusTracker<'gc> {
if let Some(old) = old {
old.on_focus_changed(context, false, new);
old.call_focus_handler(context, false, new);
}
if let Some(new) = new {
new.on_focus_changed(context, true, old);
new.call_focus_handler(context, true, old);
}
tracing::info!("Focus is now on {:?}", new);