diff --git a/src/TGUI/Loading/WidgetLoader.cpp b/src/TGUI/Loading/WidgetLoader.cpp index e8a35dc5..fad756a9 100644 --- a/src/TGUI/Loading/WidgetLoader.cpp +++ b/src/TGUI/Loading/WidgetLoader.cpp @@ -486,6 +486,16 @@ namespace tgui if (node->propertyValuePairs["maximumitems"]) comboBox->setMaximumItems(tgui::stoi(node->propertyValuePairs["maximumitems"]->value)); + if (node->propertyValuePairs["expanddirection"]) + { + if (toLower(node->propertyValuePairs["expanddirection"]->value) == "up") + comboBox->setExpandDirection(ComboBox::ExpandDirection::Up); + else if (toLower(node->propertyValuePairs["expanddirection"]->value) == "down") + comboBox->setExpandDirection(ComboBox::ExpandDirection::Down); + else + throw Exception{"Failed to parse ExpandDirection property. Only the values Up and Down are correct."}; + } + return comboBox; } diff --git a/src/TGUI/Loading/WidgetSaver.cpp b/src/TGUI/Loading/WidgetSaver.cpp index 8a57f5ba..bfbb4dfd 100644 --- a/src/TGUI/Loading/WidgetSaver.cpp +++ b/src/TGUI/Loading/WidgetSaver.cpp @@ -378,6 +378,9 @@ namespace tgui SET_PROPERTY("TextSize", to_string(comboBox->getTextSize())); SET_PROPERTY("MaximumItems", to_string(comboBox->getMaximumItems())); + if (comboBox->getExpandDirection() != ComboBox::ExpandDirection::Down) + SET_PROPERTY("ExpandDirection", "Up"); + return node; } diff --git a/tests/Widgets/ComboBox.cpp b/tests/Widgets/ComboBox.cpp index 5e909f79..48a2382b 100644 --- a/tests/Widgets/ComboBox.cpp +++ b/tests/Widgets/ComboBox.cpp @@ -362,6 +362,7 @@ TEST_CASE("[ComboBox]") comboBox->addItem("Item 3", "3"); comboBox->setItemsToDisplay(3); comboBox->setMaximumItems(5); + comboBox->setExpandDirection(tgui::ComboBox::ExpandDirection::Up); testSavingWidget("ComboBox", comboBox); }