diff -r 287b20e2a564 -r 55508508ba4d ui/win32/list.c --- a/ui/win32/list.c Sat Dec 13 12:37:41 2025 +0100 +++ b/ui/win32/list.c Sat Dec 13 12:47:36 2025 +0100 @@ -166,8 +166,8 @@ UiList *list = listview->var->value; list->obj = listview; list->update = ui_listview_update; - list->getselection = ui_listview_getselection; - list->setselection = ui_listview_setselection; + list->getselection = ui_listview_getselection_impl; + list->setselection = ui_listview_setselection_impl; ui_listview_update(list, -1); } else if (!table && args->static_elements && args->static_nelm > 0) { @@ -188,9 +188,8 @@ return (W32Widget*)listview; } -static UiListSelection listview_get_selection(UiListView *listview) { +static UiListSelection listview_get_selection2(HWND hwnd) { UiListSelection sel = { 0, NULL }; - HWND hwnd = listview->widget.hwnd; CX_ARRAY_DECLARE(int, indices); cx_array_initialize(indices, 8); @@ -208,6 +207,11 @@ return sel; } +static UiListSelection listview_get_selection(UiListView *listview) { + HWND hwnd = listview->widget.hwnd; + return listview_get_selection2(hwnd); +} + // listview class event proc int ui_listview_eventproc(W32Widget *widget, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { UiListView *listview = (UiListView*)widget; @@ -340,12 +344,12 @@ } } -UiListSelection ui_listview_getselection(UiList *list) { +UiListSelection ui_listview_getselection_impl(UiList *list) { UiListView *listview = (UiListView*)list->obj; return listview_get_selection(listview); } -void ui_listview_setselection(UiList *list, UiListSelection selection) { +void ui_listview_setselection_impl(UiList *list, UiListSelection selection) { } @@ -359,6 +363,20 @@ return listview_create(obj, args, TRUE); } +void ui_listview_select(UIWIDGET listview, int index) { + +} + +int ui_listview_selection(UIWIDGET listview) { + W32Widget *w = (W32Widget*)listview; + UiListSelection sel = listview_get_selection2(w->hwnd); + int index = -1; + if (sel.count > 0) { + index = sel.rows[0]; + } + free(sel.rows); + return index; +} /* ------------------------------------ DropDown ------------------------------------*/ @@ -396,8 +414,8 @@ UiList *list = dropdown->var->value; list->obj = dropdown; list->update = ui_dropdown_update; - list->getselection = ui_dropdown_getselection; - list->setselection = ui_dropdown_setselection; + list->getselection = ui_dropdown_getselection_impl; + list->setselection = ui_dropdown_setselection_impl; ui_dropdown_update(list, -1); } else if (args->static_elements && args->static_nelm > 0) { @@ -457,7 +475,7 @@ } } -UiListSelection ui_dropdown_getselection(UiList *list) { +UiListSelection ui_dropdown_getselection_impl(UiList *list) { UiListSelection sel = { 0, NULL }; UiListView *listview = (UiListView*)list->obj; int index = (int)SendMessage(listview->widget.hwnd, CB_GETCURSEL, 0, 0); @@ -469,7 +487,15 @@ return sel; } -void ui_dropdown_setselection(UiList *list, UiListSelection selection) { +void ui_dropdown_setselection_impl(UiList *list, UiListSelection selection) { UiListView *listview = (UiListView*)list->obj; SendMessage(listview->widget.hwnd, CB_SETCURSEL, 0, 0); } + +void ui_dropdown_select(UIWIDGET dropdown, int index) { + SendMessage(dropdown->hwnd, CB_SETCURSEL, 0, 0); +} + +int ui_dropdown_selection(UIWIDGET dropdown) { + return SendMessage(dropdown->hwnd, CB_GETCURSEL, 0, 0); +}