ui/winui/button.cpp

branch
newapi
changeset 196
320d85f3cd14
parent 192
bcacd00ea955
child 205
b1ac0dd1d38b
--- a/ui/winui/button.cpp	Mon Oct 02 10:10:09 2023 +0200
+++ b/ui/winui/button.cpp	Mon Oct 02 19:31:06 2023 +0200
@@ -68,19 +68,16 @@
 
 	// register callback
 	if (args.onclick) {
-		widget->obj = obj;
-		widget->event_func = (ui_eventfunc)args.onclick;
-		widget->event_data = args.onclickdata;
-		button.Click([widget](IInspectable const& sender, RoutedEventArgs) {
-			ui_callback cb = (ui_callback)widget->event_func;
-
+		ui_callback cbfunc = args.onclick;
+		void* cbdata = args.onclickdata;
+		button.Click([cbfunc, cbdata, obj](IInspectable const& sender, RoutedEventArgs) {
 			UiEvent evt;
-			evt.obj = (UiObject*)widget->obj;
-			evt.window = evt.obj->window;
-			evt.document = evt.obj->ctx->document;
+			evt.obj = obj;
+			evt.window = obj->window;
+			evt.document = obj->ctx->document;
 			evt.eventdata = nullptr;
 			evt.intval = 0;
-			cb(&evt, widget->event_data);
+			cbfunc(&evt, cbdata);
 			});
 	}
 

mercurial