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: Make TextField.getCharIndexAtPoint accurate #18861

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

kjarosh
Copy link
Member

@kjarosh kjarosh commented Dec 4, 2024

This patch fixes getCharIndexAtPoint() so that it's accurate for all inputs.

@kjarosh kjarosh added text Issues relating to text rendering/input A-avm2 Area: AVM2 (ActionScript 3) T-compat Type: Compatibility with Flash Player labels Dec 4, 2024
@kjarosh kjarosh marked this pull request as draft December 4, 2024 21:59
@kjarosh kjarosh force-pushed the get-char-index-at-point branch from 7398312 to 796f2e8 Compare December 4, 2024 22:55
@kjarosh kjarosh added the waiting-on-review Waiting on review from a Ruffle team member label Dec 5, 2024
@@ -2109,6 +2109,38 @@ impl<'gc> EditText<'gc> {
)
}

pub fn char_index_at_point(self, position: Point<Twips>) -> Option<usize> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you please add some docstrings to better distinguish this from screen_position_to_index? From just signature and used coordinate space they sound super similar, but name style and implementation are super different.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

This patch fixes getCharIndexAtPoint() so that it's accurate for all inputs.
This test verifies the behavior of getCharIndexAtPoint().
@kjarosh kjarosh force-pushed the get-char-index-at-point branch from 796f2e8 to 0bf3e99 Compare December 12, 2024 21:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-avm2 Area: AVM2 (ActionScript 3) T-compat Type: Compatibility with Flash Player text Issues relating to text rendering/input waiting-on-review Waiting on review from a Ruffle team member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants