Skip to content

Commit

Permalink
Fix property array tooltip shows wrong ID on later pages
Browse files Browse the repository at this point in the history
Also do some cleanup, use`element_position` instead of
`begin_array_index + i`
  • Loading branch information
jsjtxietian committed Sep 7, 2023
1 parent f7c48cf commit d4ac65b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions editor/editor_inspector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2089,8 +2089,10 @@ void EditorInspectorArray::_setup() {
ae.panel->set_focus_mode(FOCUS_ALL);
ae.panel->set_mouse_filter(MOUSE_FILTER_PASS);
SET_DRAG_FORWARDING_GCD(ae.panel, EditorInspectorArray);
ae.panel->set_meta("index", begin_array_index + i);
ae.panel->set_tooltip_text(vformat(TTR("Element %d: %s%d*"), i, array_element_prefix, i));

int element_position = begin_array_index + i;
ae.panel->set_meta("index", element_position);
ae.panel->set_tooltip_text(vformat(TTR("Element %d: %s%d*"), element_position, array_element_prefix, element_position));
ae.panel->connect("focus_entered", callable_mp((CanvasItem *)ae.panel, &PanelContainer::queue_redraw));
ae.panel->connect("focus_exited", callable_mp((CanvasItem *)ae.panel, &PanelContainer::queue_redraw));
ae.panel->connect("draw", callable_mp(this, &EditorInspectorArray::_panel_draw).bind(i));
Expand All @@ -2116,7 +2118,6 @@ void EditorInspectorArray::_setup() {

// Move button.
if (movable) {
int element_position = begin_array_index + i;
VBoxContainer *move_vbox = memnew(VBoxContainer);
move_vbox->set_v_size_flags(SIZE_EXPAND_FILL);
move_vbox->set_alignment(BoxContainer::ALIGNMENT_CENTER);
Expand Down Expand Up @@ -2152,7 +2153,7 @@ void EditorInspectorArray::_setup() {
ae.number->set_custom_minimum_size(Size2(numbers_min_w, 0));
ae.number->set_horizontal_alignment(HORIZONTAL_ALIGNMENT_RIGHT);
ae.number->set_vertical_alignment(VERTICAL_ALIGNMENT_CENTER);
ae.number->set_text(itos(begin_array_index + i));
ae.number->set_text(itos(element_position));
ae.hbox->add_child(ae.number);
}

Expand All @@ -2165,7 +2166,7 @@ void EditorInspectorArray::_setup() {
ae.erase = memnew(Button);
ae.erase->set_icon(get_theme_icon(SNAME("Remove"), SNAME("EditorIcons")));
ae.erase->set_v_size_flags(SIZE_SHRINK_CENTER);
ae.erase->connect("pressed", callable_mp(this, &EditorInspectorArray::_remove_item).bind(begin_array_index + i));
ae.erase->connect("pressed", callable_mp(this, &EditorInspectorArray::_remove_item).bind(element_position));
ae.hbox->add_child(ae.erase);
}

Expand Down

0 comments on commit d4ac65b

Please sign in to comment.