Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avm2: Ensure the focus is dropped when it's removed #16231

Merged
merged 5 commits into from
May 7, 2024

Conversation

kjarosh
Copy link
Member

@kjarosh kjarosh commented May 6, 2024

Related to #5443.

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.

Additionally, some refactors are included:

  • move has_focus to InteractiveObject, add methods has_focus, set_has_focus, drop_focus,
  • add DisplayObject.on_parent_removed method that prevents code duplication.

cc @adrian17 regarding the AVM2 button's has_focus refactor and the behavior of removing the currently held focus (which we talked about)

kjarosh added 5 commits May 7, 2024 22:43
All the interactive objects had the has_focus flag in their concrete
implementations (even AVM2 button, which did not use it at all).
This patch moves it to InteractiveObject (as a bit flag), making it
easier to manage and use through the has_focus, set_has_focus methods.

Additionally, the operation of setting the current focus to None
when an object was having it was popular enough that it warranted its
own method of drop_focus.
This method prevents code duplication performed when overwriting
set_parent to inject some behavior when the parent is 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 test verifies the behavior of Selection.getFocus()
when the focus is removed.
This test verifies the behavior of stage.focus
when the focus is removed from the stage.
@Dinnerbone Dinnerbone enabled auto-merge (rebase) May 7, 2024 20:43
@Dinnerbone Dinnerbone merged commit 45dca76 into ruffle-rs:master May 7, 2024
17 checks passed
@kjarosh kjarosh deleted the focus-unload branch May 7, 2024 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

2 participants