Skip to content

Commit

Permalink
text: Add doc to screen_position_to_index
Browse files Browse the repository at this point in the history
  • Loading branch information
kjarosh committed Dec 12, 2024
1 parent 699a06d commit 0bf3e99
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions core/src/display_object/edit_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,11 @@ impl<'gc> EditText<'gc> {
self.0.write(context.gc_context).max_chars = value;
}

/// Map the position on the screen to caret index.
///
/// This method is used exclusively for placing a caret inside text.
/// It implements the Flash Player's behavior of placing a caret.
/// Characters are divided in half, the last line is extended, etc.
pub fn screen_position_to_index(self, position: Point<Twips>) -> Option<usize> {
let text = self.0.read();
let position = self.global_to_local(position)?;
Expand Down

0 comments on commit 0bf3e99

Please sign in to comment.