Skip to content

Commit 52df1ae

Browse files
committed
ColorPicker: Fix preset button order after calling add_preset
1 parent 149a4b4 commit 52df1ae

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

scene/gui/color_picker.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1196,7 +1196,14 @@ void ColorPicker::add_preset(const Color &p_color) {
11961196
if (e) {
11971197
presets.move_to_back(e);
11981198

1199-
preset_container->move_child(preset_group->get_pressed_button(), preset_container->get_child_count() - 1);
1199+
for (int i = 1; i < preset_container->get_child_count(); i++) {
1200+
ColorPresetButton *current_btn = Object::cast_to<ColorPresetButton>(preset_container->get_child(i));
1201+
if (current_btn && p_color == current_btn->get_preset_color()) {
1202+
preset_container->move_child(current_btn, preset_container->get_child_count() - 1);
1203+
current_btn->set_pressed(true);
1204+
break;
1205+
}
1206+
}
12001207
} else {
12011208
presets.push_back(p_color);
12021209

0 commit comments

Comments
 (0)