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

Rename LineEdit getters and setters to match property names #47448

Merged
merged 1 commit into from
Apr 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 38 additions & 38 deletions doc/classes/LineEdit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,25 @@
- [kbd]Ctrl + Z[/kbd]: Undo
- [kbd]Ctrl + ~[/kbd]: Swap input direction.
- [kbd]Ctrl + Shift + Z[/kbd]: Redo
- [kbd]Ctrl + U[/kbd]: Delete text from the cursor position to the beginning of the line
- [kbd]Ctrl + K[/kbd]: Delete text from the cursor position to the end of the line
- [kbd]Ctrl + U[/kbd]: Delete text from the caret position to the beginning of the line
- [kbd]Ctrl + K[/kbd]: Delete text from the caret position to the end of the line
- [kbd]Ctrl + A[/kbd]: Select all text
- [kbd]Up Arrow[/kbd]/[kbd]Down Arrow[/kbd]: Move the cursor to the beginning/end of the line
- [kbd]Up Arrow[/kbd]/[kbd]Down Arrow[/kbd]: Move the caret to the beginning/end of the line
On macOS, some extra keyboard shortcuts are available:
- [kbd]Ctrl + F[/kbd]: Same as [kbd]Right Arrow[/kbd], move the cursor one character right
- [kbd]Ctrl + B[/kbd]: Same as [kbd]Left Arrow[/kbd], move the cursor one character left
- [kbd]Ctrl + P[/kbd]: Same as [kbd]Up Arrow[/kbd], move the cursor to the previous line
- [kbd]Ctrl + N[/kbd]: Same as [kbd]Down Arrow[/kbd], move the cursor to the next line
- [kbd]Ctrl + D[/kbd]: Same as [kbd]Delete[/kbd], delete the character on the right side of cursor
- [kbd]Ctrl + H[/kbd]: Same as [kbd]Backspace[/kbd], delete the character on the left side of the cursor
- [kbd]Ctrl + A[/kbd]: Same as [kbd]Home[/kbd], move the cursor to the beginning of the line
- [kbd]Ctrl + E[/kbd]: Same as [kbd]End[/kbd], move the cursor to the end of the line
- [kbd]Cmd + Left Arrow[/kbd]: Same as [kbd]Home[/kbd], move the cursor to the beginning of the line
- [kbd]Cmd + Right Arrow[/kbd]: Same as [kbd]End[/kbd], move the cursor to the end of the line
- [kbd]Ctrl + F[/kbd]: Same as [kbd]Right Arrow[/kbd], move the caret one character right
- [kbd]Ctrl + B[/kbd]: Same as [kbd]Left Arrow[/kbd], move the caret one character left
- [kbd]Ctrl + P[/kbd]: Same as [kbd]Up Arrow[/kbd], move the caret to the previous line
- [kbd]Ctrl + N[/kbd]: Same as [kbd]Down Arrow[/kbd], move the caret to the next line
- [kbd]Ctrl + D[/kbd]: Same as [kbd]Delete[/kbd], delete the character on the right side of caret
- [kbd]Ctrl + H[/kbd]: Same as [kbd]Backspace[/kbd], delete the character on the left side of the caret
- [kbd]Ctrl + A[/kbd]: Same as [kbd]Home[/kbd], move the caret to the beginning of the line
- [kbd]Ctrl + E[/kbd]: Same as [kbd]End[/kbd], move the caret to the end of the line
- [kbd]Cmd + Left Arrow[/kbd]: Same as [kbd]Home[/kbd], move the caret to the beginning of the line
- [kbd]Cmd + Right Arrow[/kbd]: Same as [kbd]End[/kbd], move the caret to the end of the line
madmiraal marked this conversation as resolved.
Show resolved Hide resolved
</description>
<tutorials>
</tutorials>
<methods>
<method name="append_at_cursor">
<return type="void">
</return>
<argument index="0" name="text" type="String">
</argument>
<description>
Adds [code]text[/code] after the cursor. If the resulting value is longer than [member max_length], nothing happens.
</description>
</method>
<method name="clear">
<return type="void">
</return>
Expand All @@ -54,11 +45,11 @@
Removes all OpenType features.
</description>
</method>
<method name="delete_char_at_cursor">
<method name="delete_char_at_caret">
<return type="void">
</return>
<description>
Deletes one character at the cursor's current position (equivalent to pressing [kbd]Delete[/kbd]).
Deletes one character at the caret's current position (equivalent to pressing [kbd]Delete[/kbd]).
</description>
</method>
<method name="delete_text">
Expand Down Expand Up @@ -99,7 +90,16 @@
<return type="int">
</return>
<description>
Returns the scroll offset due to [member caret_position], as a number of characters.
Returns the scroll offset due to [member caret_column], as a number of characters.
</description>
</method>
<method name="insert_text_at_caret">
<return type="void">
</return>
<argument index="0" name="text" type="String">
</argument>
<description>
Inserts [code]text[/code] at the caret. If the resulting value is longer than [member max_length], nothing happens.
</description>
</method>
<method name="menu_option">
Expand Down Expand Up @@ -159,21 +159,21 @@
<member name="align" type="int" setter="set_align" getter="get_align" enum="LineEdit.Align" default="0">
Text alignment as defined in the [enum Align] enum.
</member>
<member name="caret_blink" type="bool" setter="cursor_set_blink_enabled" getter="cursor_get_blink_enabled" default="false">
If [code]true[/code], the caret (visual cursor) blinks.
<member name="caret_blink" type="bool" setter="set_caret_blink_enabled" getter="is_caret_blink_enabled" default="false">
If [code]true[/code], the caret (text cursor) blinks.
</member>
<member name="caret_blink_speed" type="float" setter="cursor_set_blink_speed" getter="cursor_get_blink_speed" default="0.65">
<member name="caret_blink_speed" type="float" setter="set_caret_blink_speed" getter="get_caret_blink_speed" default="0.65">
Duration (in seconds) of a caret's blinking cycle.
</member>
<member name="caret_force_displayed" type="bool" setter="cursor_set_force_displayed" getter="cursor_get_force_displayed" default="false">
<member name="caret_column" type="int" setter="set_caret_column" getter="get_caret_column" default="0">
The caret's column position inside the [LineEdit]. When set, the text may scroll to accommodate it.
</member>
<member name="caret_mid_grapheme" type="bool" setter="set_mid_grapheme_caret_enabled" getter="get_mid_grapheme_caret_enabled" default="false">
<member name="caret_force_displayed" type="bool" setter="set_caret_force_displayed" getter="is_caret_force_displayed" default="false">
</member>
<member name="caret_mid_grapheme" type="bool" setter="set_caret_mid_grapheme_enabled" getter="is_caret_mid_grapheme_enabled" default="false">
Allow moving caret, selecting and removing the individual composite character components.
Note: [kbd]Backspace[/kbd] is always removing individual composite character components.
</member>
<member name="caret_position" type="int" setter="set_cursor_position" getter="get_cursor_position" default="0">
The cursor's position inside the [LineEdit]. When set, the text may scroll to accommodate it.
</member>
<member name="clear_button_enabled" type="bool" setter="set_clear_button_enabled" getter="is_clear_button_enabled" default="false">
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.
</member>
Expand All @@ -186,7 +186,7 @@
<member name="editable" type="bool" setter="set_editable" getter="is_editable" default="true">
If [code]false[/code], existing text cannot be modified and new text cannot be added.
</member>
<member name="expand_to_text_length" type="bool" setter="set_expand_to_text_length" getter="get_expand_to_text_length" default="false">
<member name="expand_to_text_length" type="bool" setter="set_expand_to_text_length_enabled" getter="is_expand_to_text_length_enabled" default="false">
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.
</member>
<member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" override="true" enum="Control.FocusMode" default="2" />
Expand Down Expand Up @@ -276,7 +276,7 @@
Copies the selected text.
</constant>
<constant name="MENU_PASTE" value="2" enum="MenuItems">
Pastes the clipboard text over the selected text (or at the cursor's position).
Pastes the clipboard text over the selected text (or at the caret's position).
Non-printable escape characters are automatically stripped from the OS clipboard via [method String.strip_escapes].
</constant>
<constant name="MENU_CLEAR" value="3" enum="MenuItems">
Expand Down Expand Up @@ -359,6 +359,9 @@
</constant>
</constants>
<theme_items>
<theme_item name="caret_color" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )">
Color of the [LineEdit]'s caret (text cursor).
</theme_item>
<theme_item name="clear" type="Texture2D">
Texture for the clear button. See [member clear_button_enabled].
</theme_item>
Expand All @@ -368,9 +371,6 @@
<theme_item name="clear_button_color_pressed" type="Color" default="Color( 1, 1, 1, 1 )">
Color used for the clear button when it's pressed.
</theme_item>
<theme_item name="cursor_color" type="Color" default="Color( 0.94, 0.94, 0.94, 1 )">
Color of the [LineEdit]'s visual cursor (caret).
</theme_item>
<theme_item name="focus" type="StyleBox">
Background used when [LineEdit] has GUI focus.
</theme_item>
Expand Down
2 changes: 1 addition & 1 deletion editor/animation_track_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2734,7 +2734,7 @@ void AnimationTrackEdit::_gui_input(const Ref<InputEvent> &p_event) {
path_popup->set_size(path_rect.size);
path_popup->popup();
path->grab_focus();
path->set_cursor_position(path->get_text().length());
path->set_caret_column(path->get_text().length());
clicking_on_name = false;
}

Expand Down
4 changes: 2 additions & 2 deletions editor/code_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,10 +488,10 @@ void FindReplaceBar::_show_search(bool p_focus_replace, bool p_show_only) {
if (!get_search_text().is_empty()) {
if (p_focus_replace) {
replace_text->select_all();
replace_text->set_cursor_position(replace_text->get_text().length());
replace_text->set_caret_column(replace_text->get_text().length());
} else {
search_text->select_all();
search_text->set_cursor_position(search_text->get_text().length());
search_text->set_caret_column(search_text->get_text().length());
}

results_count = -1;
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_help.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1801,7 +1801,7 @@ void FindBar::popup_search() {

if (!search_text->get_text().is_empty()) {
search_text->select_all();
search_text->set_cursor_position(search_text->get_text().length());
search_text->set_caret_column(search_text->get_text().length());
if (grabbed_focus) {
_search();
}
Expand Down
2 changes: 1 addition & 1 deletion editor/editor_themes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) {
theme->set_color("read_only", "LineEdit", font_disabled_color);
theme->set_color("font_color", "LineEdit", font_color);
theme->set_color("font_selected_color", "LineEdit", mono_color);
theme->set_color("cursor_color", "LineEdit", font_color);
theme->set_color("caret_color", "LineEdit", font_color);
theme->set_color("selection_color", "LineEdit", selection_color);
theme->set_color("clear_button_color", "LineEdit", font_color);
theme->set_color("clear_button_color_pressed", "LineEdit", accent_color);
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/animation_blend_space_1d_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ AnimationNodeBlendSpace1DEditor::AnimationNodeBlendSpace1DEditor() {
max_value->set_step(0.01);

label_value = memnew(LineEdit);
label_value->set_expand_to_text_length(true);
label_value->set_expand_to_text_length_enabled(true);

// now add

Expand Down
4 changes: 2 additions & 2 deletions editor/plugins/animation_blend_space_2d_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ AnimationNodeBlendSpace2DEditor::AnimationNodeBlendSpace2DEditor() {
left_vbox->add_spacer();
label_y = memnew(LineEdit);
left_vbox->add_child(label_y);
label_y->set_expand_to_text_length(true);
label_y->set_expand_to_text_length_enabled(true);
left_vbox->add_spacer();
min_y_value = memnew(SpinBox);
left_vbox->add_child(min_y_value);
Expand Down Expand Up @@ -978,7 +978,7 @@ AnimationNodeBlendSpace2DEditor::AnimationNodeBlendSpace2DEditor() {
bottom_vbox->add_spacer();
label_x = memnew(LineEdit);
bottom_vbox->add_child(label_x);
label_x->set_expand_to_text_length(true);
label_x->set_expand_to_text_length_enabled(true);
bottom_vbox->add_spacer();
max_x_value = memnew(SpinBox);
bottom_vbox->add_child(max_x_value);
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/animation_blend_tree_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void AnimationNodeBlendTreeEditor::_update_graph() {
if (String(E->get()) != "output") {
LineEdit *name = memnew(LineEdit);
name->set_text(E->get());
name->set_expand_to_text_length(true);
name->set_expand_to_text_length_enabled(true);
node->add_child(name);
node->set_slot(0, false, 0, Color(), true, 0, get_theme_color("font_color", "Label"));
name->connect("text_entered", callable_mp(this, &AnimationNodeBlendTreeEditor::_node_renamed), varray(agnode), CONNECT_DEFERRED);
Expand Down
2 changes: 1 addition & 1 deletion editor/plugins/visual_shader_editor_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3671,7 +3671,7 @@ VisualShaderEditor::VisualShaderEditor() {

comment_title_change_popup = memnew(PopupPanel);
comment_title_change_edit = memnew(LineEdit);
comment_title_change_edit->set_expand_to_text_length(true);
comment_title_change_edit->set_expand_to_text_length_enabled(true);
comment_title_change_edit->connect("text_changed", callable_mp(this, &VisualShaderEditor::_comment_title_text_changed));
comment_title_change_edit->connect("text_entered", callable_mp(this, &VisualShaderEditor::_comment_title_text_entered));
comment_title_change_popup->add_child(comment_title_change_edit);
Expand Down
2 changes: 1 addition & 1 deletion editor/rename_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ void RenameDialog::_insert_text(String text) {

if (_is_main_field(focus_owner)) {
focus_owner->selection_delete();
focus_owner->append_at_cursor(text);
focus_owner->insert_text_at_caret(text);
_update_preview();
}
}
Expand Down
6 changes: 3 additions & 3 deletions editor/script_create_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ void ScriptCreateDialog::_path_hbox_sorted() {

// First set cursor to the end of line to scroll LineEdit view
// to the right and then set the actual cursor position.
file_path->set_cursor_position(file_path->get_text().length());
file_path->set_cursor_position(filename_start_pos);
file_path->set_caret_column(file_path->get_text().length());
file_path->set_caret_column(filename_start_pos);

file_path->grab_focus();
}
Expand Down Expand Up @@ -557,7 +557,7 @@ void ScriptCreateDialog::_file_selected(const String &p_file) {
String filename = p.get_file().get_basename();
int select_start = p.rfind(filename);
file_path->select(select_start, select_start + filename.length());
file_path->set_cursor_position(select_start + filename.length());
file_path->set_caret_column(select_start + filename.length());
file_path->grab_focus();
}
}
Expand Down
8 changes: 4 additions & 4 deletions modules/visual_script/visual_script_editor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
has_gnode_text = true;
LineEdit *line_edit = memnew(LineEdit);
line_edit->set_text(node->get_text());
line_edit->set_expand_to_text_length(true);
line_edit->set_expand_to_text_length_enabled(true);
line_edit->add_theme_font_override("font", get_theme_font("source", "EditorFonts"));
gnode->add_child(line_edit);
line_edit->connect("text_changed", callable_mp(this, &VisualScriptEditor::_expression_text_changed), varray(E->get()));
Expand Down Expand Up @@ -843,7 +843,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
hbc->add_child(name_box);
name_box->set_custom_minimum_size(Size2(60 * EDSCALE, 0));
name_box->set_text(left_name);
name_box->set_expand_to_text_length(true);
name_box->set_expand_to_text_length_enabled(true);
name_box->connect("resized", callable_mp(this, &VisualScriptEditor::_update_node_size), varray(E->get()));
name_box->connect("focus_exited", callable_mp(this, &VisualScriptEditor::_port_name_focus_out), varray(name_box, E->get(), i, true));
} else {
Expand Down Expand Up @@ -938,7 +938,7 @@ void VisualScriptEditor::_update_graph(int p_only_id) {
hbc->add_child(name_box);
name_box->set_custom_minimum_size(Size2(60 * EDSCALE, 0));
name_box->set_text(right_name);
name_box->set_expand_to_text_length(true);
name_box->set_expand_to_text_length_enabled(true);
name_box->connect("resized", callable_mp(this, &VisualScriptEditor::_update_node_size), varray(E->get()));
name_box->connect("focus_exited", callable_mp(this, &VisualScriptEditor::_port_name_focus_out), varray(name_box, E->get(), i, false));
} else {
Expand Down Expand Up @@ -4322,7 +4322,7 @@ VisualScriptEditor::VisualScriptEditor() {
function_name_box = memnew(LineEdit);
function_name_edit->add_child(function_name_box);
function_name_box->connect("gui_input", callable_mp(this, &VisualScriptEditor::_fn_name_box_input));
function_name_box->set_expand_to_text_length(true);
function_name_box->set_expand_to_text_length_enabled(true);
add_child(function_name_edit);

/// Actual Graph ///
Expand Down
Loading