Skip to content

Commit 8ba06e3

Browse files
authored
Merge pull request godotengine#47448 from madmiraal/rename-lineedit-cursor
Rename LineEdit getters and setters to match property names
2 parents f41e777 + 86822b1 commit 8ba06e3

15 files changed

+248
-248
lines changed

doc/classes/LineEdit.xml

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -12,34 +12,25 @@
1212
- [kbd]Ctrl + Z[/kbd]: Undo
1313
- [kbd]Ctrl + ~[/kbd]: Swap input direction.
1414
- [kbd]Ctrl + Shift + Z[/kbd]: Redo
15-
- [kbd]Ctrl + U[/kbd]: Delete text from the cursor position to the beginning of the line
16-
- [kbd]Ctrl + K[/kbd]: Delete text from the cursor position to the end of the line
15+
- [kbd]Ctrl + U[/kbd]: Delete text from the caret position to the beginning of the line
16+
- [kbd]Ctrl + K[/kbd]: Delete text from the caret position to the end of the line
1717
- [kbd]Ctrl + A[/kbd]: Select all text
18-
- [kbd]Up Arrow[/kbd]/[kbd]Down Arrow[/kbd]: Move the cursor to the beginning/end of the line
18+
- [kbd]Up Arrow[/kbd]/[kbd]Down Arrow[/kbd]: Move the caret to the beginning/end of the line
1919
On macOS, some extra keyboard shortcuts are available:
20-
- [kbd]Ctrl + F[/kbd]: Same as [kbd]Right Arrow[/kbd], move the cursor one character right
21-
- [kbd]Ctrl + B[/kbd]: Same as [kbd]Left Arrow[/kbd], move the cursor one character left
22-
- [kbd]Ctrl + P[/kbd]: Same as [kbd]Up Arrow[/kbd], move the cursor to the previous line
23-
- [kbd]Ctrl + N[/kbd]: Same as [kbd]Down Arrow[/kbd], move the cursor to the next line
24-
- [kbd]Ctrl + D[/kbd]: Same as [kbd]Delete[/kbd], delete the character on the right side of cursor
25-
- [kbd]Ctrl + H[/kbd]: Same as [kbd]Backspace[/kbd], delete the character on the left side of the cursor
26-
- [kbd]Ctrl + A[/kbd]: Same as [kbd]Home[/kbd], move the cursor to the beginning of the line
27-
- [kbd]Ctrl + E[/kbd]: Same as [kbd]End[/kbd], move the cursor to the end of the line
28-
- [kbd]Cmd + Left Arrow[/kbd]: Same as [kbd]Home[/kbd], move the cursor to the beginning of the line
29-
- [kbd]Cmd + Right Arrow[/kbd]: Same as [kbd]End[/kbd], move the cursor to the end of the line
20+
- [kbd]Ctrl + F[/kbd]: Same as [kbd]Right Arrow[/kbd], move the caret one character right
21+
- [kbd]Ctrl + B[/kbd]: Same as [kbd]Left Arrow[/kbd], move the caret one character left
22+
- [kbd]Ctrl + P[/kbd]: Same as [kbd]Up Arrow[/kbd], move the caret to the previous line
23+
- [kbd]Ctrl + N[/kbd]: Same as [kbd]Down Arrow[/kbd], move the caret to the next line
24+
- [kbd]Ctrl + D[/kbd]: Same as [kbd]Delete[/kbd], delete the character on the right side of caret
25+
- [kbd]Ctrl + H[/kbd]: Same as [kbd]Backspace[/kbd], delete the character on the left side of the caret
26+
- [kbd]Ctrl + A[/kbd]: Same as [kbd]Home[/kbd], move the caret to the beginning of the line
27+
- [kbd]Ctrl + E[/kbd]: Same as [kbd]End[/kbd], move the caret to the end of the line
28+
- [kbd]Cmd + Left Arrow[/kbd]: Same as [kbd]Home[/kbd], move the caret to the beginning of the line
29+
- [kbd]Cmd + Right Arrow[/kbd]: Same as [kbd]End[/kbd], move the caret to the end of the line
3030
</description>
3131
<tutorials>
3232
</tutorials>
3333
<methods>
34-
<method name="append_at_cursor">
35-
<return type="void">
36-
</return>
37-
<argument index="0" name="text" type="String">
38-
</argument>
39-
<description>
40-
Adds [code]text[/code] after the cursor. If the resulting value is longer than [member max_length], nothing happens.
41-
</description>
42-
</method>
4334
<method name="clear">
4435
<return type="void">
4536
</return>
@@ -54,11 +45,11 @@
5445
Removes all OpenType features.
5546
</description>
5647
</method>
57-
<method name="delete_char_at_cursor">
48+
<method name="delete_char_at_caret">
5849
<return type="void">
5950
</return>
6051
<description>
61-
Deletes one character at the cursor's current position (equivalent to pressing [kbd]Delete[/kbd]).
52+
Deletes one character at the caret's current position (equivalent to pressing [kbd]Delete[/kbd]).
6253
</description>
6354
</method>
6455
<method name="delete_text">
@@ -99,7 +90,16 @@
9990
<return type="int">
10091
</return>
10192
<description>
102-
Returns the scroll offset due to [member caret_position], as a number of characters.
93+
Returns the scroll offset due to [member caret_column], as a number of characters.
94+
</description>
95+
</method>
96+
<method name="insert_text_at_caret">
97+
<return type="void">
98+
</return>
99+
<argument index="0" name="text" type="String">
100+
</argument>
101+
<description>
102+
Inserts [code]text[/code] at the caret. If the resulting value is longer than [member max_length], nothing happens.
103103
</description>
104104
</method>
105105
<method name="menu_option">
@@ -159,21 +159,21 @@
159159
<member name="align" type="int" setter="set_align" getter="get_align" enum="LineEdit.Align" default="0">
160160
Text alignment as defined in the [enum Align] enum.
161161
</member>
162-
<member name="caret_blink" type="bool" setter="cursor_set_blink_enabled" getter="cursor_get_blink_enabled" default="false">
163-
If [code]true[/code], the caret (visual cursor) blinks.
162+
<member name="caret_blink" type="bool" setter="set_caret_blink_enabled" getter="is_caret_blink_enabled" default="false">
163+
If [code]true[/code], the caret (text cursor) blinks.
164164
</member>
165-
<member name="caret_blink_speed" type="float" setter="cursor_set_blink_speed" getter="cursor_get_blink_speed" default="0.65">
165+
<member name="caret_blink_speed" type="float" setter="set_caret_blink_speed" getter="get_caret_blink_speed" default="0.65">
166166
Duration (in seconds) of a caret's blinking cycle.
167167
</member>
168-
<member name="caret_force_displayed" type="bool" setter="cursor_set_force_displayed" getter="cursor_get_force_displayed" default="false">
168+
<member name="caret_column" type="int" setter="set_caret_column" getter="get_caret_column" default="0">
169+
The caret's column position inside the [LineEdit]. When set, the text may scroll to accommodate it.
169170
</member>
170-
<member name="caret_mid_grapheme" type="bool" setter="set_mid_grapheme_caret_enabled" getter="get_mid_grapheme_caret_enabled" default="false">
171+
<member name="caret_force_displayed" type="bool" setter="set_caret_force_displayed" getter="is_caret_force_displayed" default="false">
172+
</member>
173+
<member name="caret_mid_grapheme" type="bool" setter="set_caret_mid_grapheme_enabled" getter="is_caret_mid_grapheme_enabled" default="false">
171174
Allow moving caret, selecting and removing the individual composite character components.
172175
Note: [kbd]Backspace[/kbd] is always removing individual composite character components.
173176
</member>
174-
<member name="caret_position" type="int" setter="set_cursor_position" getter="get_cursor_position" default="0">
175-
The cursor's position inside the [LineEdit]. When set, the text may scroll to accommodate it.
176-
</member>
177177
<member name="clear_button_enabled" type="bool" setter="set_clear_button_enabled" getter="is_clear_button_enabled" default="false">
178178
If [code]true[/code], the [LineEdit] will show a clear button if [code]text[/code] is not empty, which can be used to clear the text quickly.
179179
</member>
@@ -186,7 +186,7 @@
186186
<member name="editable" type="bool" setter="set_editable" getter="is_editable" default="true">
187187
If [code]false[/code], existing text cannot be modified and new text cannot be added.
188188
</member>
189-
<member name="expand_to_text_length" type="bool" setter="set_expand_to_text_length" getter="get_expand_to_text_length" default="false">
189+
<member name="expand_to_text_length" type="bool" setter="set_expand_to_text_length_enabled" getter="is_expand_to_text_length_enabled" default="false">
190190
If [code]true[/code], the [LineEdit] width will increase to stay longer than the [member text]. It will [b]not[/b] compress if the [member text] is shortened.
191191
</member>
192192
<member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" override="true" enum="Control.FocusMode" default="2" />
@@ -276,7 +276,7 @@
276276
Copies the selected text.
277277
</constant>
278278
<constant name="MENU_PASTE" value="2" enum="MenuItems">
279-
Pastes the clipboard text over the selected text (or at the cursor's position).
279+
Pastes the clipboard text over the selected text (or at the caret's position).
280280
Non-printable escape characters are automatically stripped from the OS clipboard via [method String.strip_escapes].
281281
</constant>
282282
<constant name="MENU_CLEAR" value="3" enum="MenuItems">
@@ -359,6 +359,9 @@
359359
</constant>
360360
</constants>
361361
<theme_items>
362+
<theme_item name="caret_color" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )">
363+
Color of the [LineEdit]'s caret (text cursor).
364+
</theme_item>
362365
<theme_item name="clear" type="Texture2D">
363366
Texture for the clear button. See [member clear_button_enabled].
364367
</theme_item>
@@ -368,9 +371,6 @@
368371
<theme_item name="clear_button_color_pressed" type="Color" default="Color( 1, 1, 1, 1 )">
369372
Color used for the clear button when it's pressed.
370373
</theme_item>
371-
<theme_item name="cursor_color" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )">
372-
Color of the [LineEdit]'s visual cursor (caret).
373-
</theme_item>
374374
<theme_item name="focus" type="StyleBox">
375375
Background used when [LineEdit] has GUI focus.
376376
</theme_item>

editor/animation_track_editor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2734,7 +2734,7 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
27342734
path_popup->set_size(path_rect.size);
27352735
path_popup->popup();
27362736
path->grab_focus();
2737-
path->set_cursor_position(path->get_text().length());
2737+
path->set_caret_column(path->get_text().length());
27382738
clicking_on_name = false;
27392739
}
27402740

editor/code_editor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,10 +488,10 @@ void FindReplaceBar::_show_search(bool p_focus_replace, bool p_show_only) {
488488
if (!get_search_text().is_empty()) {
489489
if (p_focus_replace) {
490490
replace_text->select_all();
491-
replace_text->set_cursor_position(replace_text->get_text().length());
491+
replace_text->set_caret_column(replace_text->get_text().length());
492492
} else {
493493
search_text->select_all();
494-
search_text->set_cursor_position(search_text->get_text().length());
494+
search_text->set_caret_column(search_text->get_text().length());
495495
}
496496

497497
results_count = -1;

editor/editor_help.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1801,7 +1801,7 @@ void FindBar::popup_search() {
18011801

18021802
if (!search_text->get_text().is_empty()) {
18031803
search_text->select_all();
1804-
search_text->set_cursor_position(search_text->get_text().length());
1804+
search_text->set_caret_column(search_text->get_text().length());
18051805
if (grabbed_focus) {
18061806
_search();
18071807
}

editor/editor_themes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -963,7 +963,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
963963
theme->set_color("read_only", "LineEdit", font_disabled_color);
964964
theme->set_color("font_color", "LineEdit", font_color);
965965
theme->set_color("font_selected_color", "LineEdit", mono_color);
966-
theme->set_color("cursor_color", "LineEdit", font_color);
966+
theme->set_color("caret_color", "LineEdit", font_color);
967967
theme->set_color("selection_color", "LineEdit", selection_color);
968968
theme->set_color("clear_button_color", "LineEdit", font_color);
969969
theme->set_color("clear_button_color_pressed", "LineEdit", accent_color);

editor/plugins/animation_blend_space_1d_editor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ AnimationNodeBlendSpace1DEditor::AnimationNodeBlendSpace1DEditor() {
698698
max_value->set_step(0.01);
699699

700700
label_value = memnew(LineEdit);
701-
label_value->set_expand_to_text_length(true);
701+
label_value->set_expand_to_text_length_enabled(true);
702702

703703
// now add
704704

editor/plugins/animation_blend_space_2d_editor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ AnimationNodeBlendSpace2DEditor::AnimationNodeBlendSpace2DEditor() {
942942
left_vbox->add_spacer();
943943
label_y = memnew(LineEdit);
944944
left_vbox->add_child(label_y);
945-
label_y->set_expand_to_text_length(true);
945+
label_y->set_expand_to_text_length_enabled(true);
946946
left_vbox->add_spacer();
947947
min_y_value = memnew(SpinBox);
948948
left_vbox->add_child(min_y_value);
@@ -978,7 +978,7 @@ AnimationNodeBlendSpace2DEditor::AnimationNodeBlendSpace2DEditor() {
978978
bottom_vbox->add_spacer();
979979
label_x = memnew(LineEdit);
980980
bottom_vbox->add_child(label_x);
981-
label_x->set_expand_to_text_length(true);
981+
label_x->set_expand_to_text_length_enabled(true);
982982
bottom_vbox->add_spacer();
983983
max_x_value = memnew(SpinBox);
984984
bottom_vbox->add_child(max_x_value);

editor/plugins/animation_blend_tree_editor_plugin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() {
136136
if (String(E->get()) != "output") {
137137
LineEdit *name = memnew(LineEdit);
138138
name->set_text(E->get());
139-
name->set_expand_to_text_length(true);
139+
name->set_expand_to_text_length_enabled(true);
140140
node->add_child(name);
141141
node->set_slot(0, false, 0, Color(), true, 0, get_theme_color("font_color", "Label"));
142142
name->connect("text_entered", callable_mp(this, &AnimationNodeBlendTreeEditor::_node_renamed), varray(agnode), CONNECT_DEFERRED);

editor/plugins/visual_shader_editor_plugin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3695,7 +3695,7 @@ VisualShaderEditor::VisualShaderEditor() {
36953695

36963696
comment_title_change_popup = memnew(PopupPanel);
36973697
comment_title_change_edit = memnew(LineEdit);
3698-
comment_title_change_edit->set_expand_to_text_length(true);
3698+
comment_title_change_edit->set_expand_to_text_length_enabled(true);
36993699
comment_title_change_edit->connect("text_changed", callable_mp(this, &VisualShaderEditor::_comment_title_text_changed));
37003700
comment_title_change_edit->connect("text_entered", callable_mp(this, &VisualShaderEditor::_comment_title_text_entered));
37013701
comment_title_change_popup->add_child(comment_title_change_edit);

editor/rename_dialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ void RenameDialog::_insert_text(String text) {
632632

633633
if (_is_main_field(focus_owner)) {
634634
focus_owner->selection_delete();
635-
focus_owner->append_at_cursor(text);
635+
focus_owner->insert_text_at_caret(text);
636636
_update_preview();
637637
}
638638
}

0 commit comments

Comments
 (0)