ui/qt/button.cpp

changeset 551
0e543e1d060e
parent 550
0412c4c1048e
child 559
dc5ed4c10d83
--- a/ui/qt/button.cpp	Fri Apr 04 22:16:29 2025 +0200
+++ b/ui/qt/button.cpp	Sat Apr 05 11:21:02 2025 +0200
@@ -165,6 +165,14 @@
 }
 
 
+static void radiobutton_event(UiEvent *event, UiEventWrapper *wrapper) {
+    if(wrapper->var) {
+        UiInteger *value = wrapper->var->value;
+        event->eventdata = value;
+        event->intval = ui_get(value);
+    }
+}
+
 UIWIDGET ui_radiobutton_create(UiObject *obj, UiToggleArgs args) {
     UiContainerPrivate *ctn = ui_obj_container(obj);
     UI_APPLY_LAYOUT(ctn->layout, args);
@@ -190,9 +198,12 @@
         value->set = ui_radiobutton_set;
     }
     
-    // TODO: unbind var/remove button from buttongroup when the button is destroyed
-    // TODO: implement callback
-    // TODO: implement value observer
+    UiEventWrapper *event = new UiEventWrapper(obj, args.onchange, args.onchangedata);
+    event->var = var;
+    event->customdata1 = button;
+    event->prepare_event = togglebutton_event;
+    button->connect(button, SIGNAL(clicked()), event, SLOT(slot()));
+    button->connect(button, SIGNAL(destroyed()), event, SLOT(destroy()));
     
     ctn->add(button, false);
     

mercurial