# HG changeset patch # User Olaf Wintermann # Date 1706533320 -3600 # Node ID 56621137b8e19840790260004a37a01691397c41 # Parent 8649c6a29e6d960557c5a9902af9d4b2209e699e add event handler for menu item lists diff -r 8649c6a29e6d -r 56621137b8e1 ui/winui/appmenu.cpp --- a/ui/winui/appmenu.cpp Mon Jan 29 12:19:21 2024 +0100 +++ b/ui/winui/appmenu.cpp Mon Jan 29 14:02:00 2024 +0100 @@ -165,6 +165,7 @@ class UiMenuList { public: + UiObject *obj = nullptr; winrt::Windows::Foundation::Collections::IVector parent = { nullptr }; UiMenuItemType type; int prevSize = 0; @@ -197,6 +198,19 @@ mi.Text(wlabel); free(wlabel); + if (callback) { + mi.Click([this, elm, count](Windows::Foundation::IInspectable const& sender, RoutedEventArgs const& e) + { + UiEvent evt; + evt.obj = obj; + evt.window = obj->window; + evt.document = obj->ctx->document; + evt.eventdata = elm; + evt.intval = count; + callback(&evt, userdata); + }); + } + parent.InsertAt(insertPos + count, mi); elm = list->next(list); @@ -237,6 +251,7 @@ UiVar* var = uic_create_var(ui_global_context(), it->varname, UI_VAR_LIST); UiMenuList* mlist = new UiMenuList(); + mlist->obj = obj; mlist->parent = parent; mlist->getvalue = it->getvalue; mlist->callback = it->callback;