# HG changeset patch # User Olaf Wintermann # Date 1697740696 -7200 # Node ID 1121b61f8828b81d7eb598afc9308c018ac5837f # Parent a82d9beaa94a827623828e16e22469ec25c15d19 implement pathbar action (WinUI3) diff -r a82d9beaa94a -r 1121b61f8828 ui/winui/list.cpp --- a/ui/winui/list.cpp Thu Oct 19 18:30:19 2023 +0200 +++ b/ui/winui/list.cpp Thu Oct 19 20:38:16 2023 +0200 @@ -283,6 +283,7 @@ uipathbar->grid = content; uipathbar->buttons = buttons; uipathbar->textbox = pathTextBox; + uipathbar->obj = obj; uipathbar->enabledrag = args.enabledrag; uipathbar->enabledrop = args.enabledrop; uipathbar->getvalue = args.getvalue; @@ -415,6 +416,7 @@ // add new buttons void* elm = list->first(list); + int j = 0; while (elm) { char* value = (char*)getvalue(elm, 0); wchar_t* wstr = str2wstr(value, nullptr); @@ -422,6 +424,18 @@ button.Content(box_value(wstr)); free(wstr); + if (pb->onactivate) { + button.Click([pb, j](IInspectable const& sender, RoutedEventArgs) { + UiEvent evt; + evt.obj = pb->obj; + evt.window = evt.obj->window; + evt.document = evt.obj->ctx->document; + evt.eventdata = nullptr; + evt.intval = j; + pb->onactivate(&evt, pb->onactivatedata); + }); + } + Thickness t = { 0, 0, 1, 0 }; CornerRadius c = { 0 ,0, 0, 0 }; button.BorderThickness(t); @@ -429,6 +443,7 @@ pb->buttons.Children().Append(button); + j++; elm = list->next(list); } } diff -r a82d9beaa94a -r 1121b61f8828 ui/winui/list.h --- a/ui/winui/list.h Thu Oct 19 18:30:19 2023 +0200 +++ b/ui/winui/list.h Thu Oct 19 20:38:16 2023 +0200 @@ -38,6 +38,7 @@ winrt::Microsoft::UI::Xaml::Controls::StackPanel buttons = { nullptr }; winrt::Microsoft::UI::Xaml::Controls::TextBox textbox = { nullptr }; + UiObject* obj; UiModel* model; ui_getvaluefunc getvalue; ui_callback onactivate;