Prevent LineEdit from losing focus when text is submitted or rejected.

This commit is contained in:
Mounir Tohami
2024-09-10 13:43:31 +00:00
parent d0dc3896ad
commit c36f466a4c
6 changed files with 411 additions and 310 deletions

View File

@@ -4,7 +4,14 @@
An input field for single-line text.
</brief_description>
<description>
[LineEdit] provides an input field for editing a single line of text. It features many built-in shortcuts that are always available ([kbd]Ctrl[/kbd] here maps to [kbd]Cmd[/kbd] on macOS):
[LineEdit] provides an input field for editing a single line of text.
- When the [LineEdit] control is focused using the keyboard arrow keys, it will only gain focus and not enter edit mode.
- To enter edit mode, click on the control with the mouse or press the "ui_text_submit" action (default: [kbd]Enter[/kbd] or [kbd]Kp Enter[/kbd]).
- To exit edit mode, press "ui_text_submit" or "ui_cancel" (default: [kbd]Escape[/kbd]) actions.
- Check [method is_editing] and [signal editing_toggled] for more information.
[b]Important:[/b]
- Focusing the [LineEdit] with "ui_focus_next" (default: [kbd]Tab[/kbd]) or "ui_focus_prev" (default: [kbd]Shift + Tab[/kbd]) or [method Control.grab_focus] still enters edit mode (for compatibility).
[LineEdit] features many built-in shortcuts that are always available ([kbd]Ctrl[/kbd] here maps to [kbd]Cmd[/kbd] on macOS):
- [kbd]Ctrl + C[/kbd]: Copy
- [kbd]Ctrl + X[/kbd]: Cut
- [kbd]Ctrl + V[/kbd] or [kbd]Ctrl + Y[/kbd]: Paste/"yank"
@@ -139,6 +146,12 @@
Inserts [param text] at the caret. If the resulting value is longer than [member max_length], nothing happens.
</description>
</method>
<method name="is_editing" qualifiers="const">
<return type="bool" />
<description>
Returns whether the [LineEdit] is being edited.
</description>
</method>
<method name="is_menu_visible" qualifiers="const">
<return type="bool" />
<description>
@@ -301,6 +314,12 @@
</member>
</members>
<signals>
<signal name="editing_toggled">
<param index="0" name="toggled_on" type="bool" />
<description>
Emitted when the [LineEdit] switches in or out of edit mode.
</description>
</signal>
<signal name="text_change_rejected">
<param index="0" name="rejected_substring" type="String" />
<description>