Adds get_selection_line_offset to RichTextLabel

This new method allow you to get the line offset of the current
selection (returns -1 if nothing is selected.)

This is useful if you want to pop up a control or menu above the
currently selected text. Previously there was no accurate way to get
this information.

The logic is moved from the implementation of `scroll_to_selection`
verbatim, and that method has been adjusted to avoid repetition.
This commit is contained in:
Robin Ward
2024-12-12 12:06:09 -05:00
parent 19e003bc08
commit b3e970dde8
3 changed files with 36 additions and 19 deletions

View File

@@ -190,6 +190,12 @@
Returns the current selection first character index if a selection is active, [code]-1[/code] otherwise. Does not include BBCodes.
</description>
</method>
<method name="get_selection_line_offset" qualifiers="const">
<return type="float" />
<description>
Returns the current selection vertical line offset if a selection is active, [code]-1.0[/code] otherwise.
</description>
</method>
<method name="get_selection_to" qualifiers="const">
<return type="int" />
<description>