summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/util.c26
-rw-r--r--src/ui/util.h1
2 files changed, 27 insertions, 0 deletions
diff --git a/src/ui/util.c b/src/ui/util.c
index efcb8b9f..912e1d37 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -1298,6 +1298,32 @@ void updateDropdownSelection_LabelWidget(iLabelWidget *dropButton, const char *s
1298 } 1298 }
1299} 1299}
1300 1300
1301const char *selectedDropdownCommand_LabelWidget(const iLabelWidget *dropButton) {
1302 if (!dropButton) {
1303 return "";
1304 }
1305 iWidget *menu = findChild_Widget(constAs_Widget(dropButton), "menu");
1306 if (flags_Widget(menu) & nativeMenu_WidgetFlag) {
1307 iConstForEach(Array, i, userData_Object(menu)) {
1308 const iMenuItem *item = i.value;
1309 if (item->label && startsWithCase_CStr(item->label, "###")) {
1310 return item->command ? item->command : "";
1311 }
1312 }
1313 }
1314 else {
1315 iForEach(ObjectList, i, children_Widget(menu)) {
1316 if (isInstance_Object(i.object, &Class_LabelWidget)) {
1317 iLabelWidget *item = i.object;
1318 if (flags_Widget(i.object) & selected_WidgetFlag) {
1319 return cstr_String(command_LabelWidget(item));
1320 }
1321 }
1322 }
1323 }
1324 return "";
1325}
1326
1301/*-----------------------------------------------------------------------------------------------*/ 1327/*-----------------------------------------------------------------------------------------------*/
1302 1328
1303static iBool isTabPage_Widget_(const iWidget *tabs, const iWidget *page) { 1329static iBool isTabPage_Widget_(const iWidget *tabs, const iWidget *page) {
diff --git a/src/ui/util.h b/src/ui/util.h
index 81fb1cbd..d13d751b 100644
--- a/src/ui/util.h
+++ b/src/ui/util.h
@@ -261,6 +261,7 @@ int checkContextMenu_Widget (iWidget *, const SDL_Event *ev)
261 261
262iLabelWidget * makeMenuButton_LabelWidget (const char *label, const iMenuItem *items, size_t n); 262iLabelWidget * makeMenuButton_LabelWidget (const char *label, const iMenuItem *items, size_t n);
263void updateDropdownSelection_LabelWidget (iLabelWidget *dropButton, const char *selectedCommand); 263void updateDropdownSelection_LabelWidget (iLabelWidget *dropButton, const char *selectedCommand);
264const char * selectedDropdownCommand_LabelWidget (const iLabelWidget *dropButton);
264 265
265/*-----------------------------------------------------------------------------------------------*/ 266/*-----------------------------------------------------------------------------------------------*/
266 267