--- a/ui/win32/button.c Thu Oct 09 18:24:09 2025 +0200 +++ b/ui/win32/button.c Thu Oct 09 18:49:19 2025 +0200 @@ -29,7 +29,11 @@ #include "button.h" #include "widget.h" +#include <stdio.h> +#include <stdlib.h> + static W32WidgetClass button_widget_class = { + .eventproc = ui_button_eventproc, .enable = w32_widget_default_enable, .show = w32_widget_default_show, .get_preferred_size = ui_button_get_preferred_size, @@ -53,9 +57,14 @@ NULL); ui_win32_set_ui_font(hwnd); - W32Widget *widget = w32_widget_create(&button_widget_class, hwnd, sizeof(UiButton)); + W32Widget *widget = w32_widget_create(&button_widget_class, hwnd, sizeof(UiWidget)); ui_container_add(container, widget, &layout); + UiWidget *btn = (UiWidget*)widget; + btn->obj = obj; + btn->callback = args->onclick; + btn->callbackdata = args->onclickdata; + return widget; } @@ -65,3 +74,20 @@ size.height = 30; return size; } + +void ui_button_eventproc(W32Widget *widget, HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { + UiWidget *w = (UiWidget*)widget; + + UiEvent e; + e.obj = w->obj; + e.document = e.obj->ctx->document; + e.window = e.obj->window; + e.eventdata = NULL; + e.eventdatatype = 0; + e.intval = 0; + e.set = ui_get_setop(); + + if (w->callback) { + w->callback(&e, w->callbackdata); + } +}