# HG changeset patch # User Olaf Wintermann # Date 1766510644 -3600 # Node ID cae4af4174249e3dfb922555d905f9c5c30bd291 # Parent 9fe8bff5c652f276de944fa5dcbb7d26a9057d67 change intval in menu radio button onchange event to contain the button state diff -r 9fe8bff5c652 -r cae4af417424 application/main.c --- a/application/main.c Mon Dec 22 09:19:24 2025 +0100 +++ b/application/main.c Tue Dec 23 18:24:04 2025 +0100 @@ -616,6 +616,10 @@ ui_draw_rect(g, (g->width/2)-80, (g->height/2)-40, 160, 80, FALSE); } +static void action_menu_radio(UiEvent *event, void *userdata) { + printf("option: %d\n", event->intval); +} + void application_startup(UiEvent *event, void *data) { // global list UiContext *global = ui_global_context(); @@ -898,9 +902,9 @@ ui_menuitem("Save"); ui_menuseparator(); - ui_menu_radioitem(.label = "Option 1", .varname = "menu_radio"); - ui_menu_radioitem(.label = "Option 2", .varname = "menu_radio"); - ui_menu_radioitem(.label = "Option 3", .varname = "menu_radio"); + ui_menu_radioitem(.label = "Option 1", .varname = "menu_radio", .onchange = action_menu_radio); + ui_menu_radioitem(.label = "Option 2", .varname = "menu_radio", .onchange = action_menu_radio); + ui_menu_radioitem(.label = "Option 3", .varname = "menu_radio", .onchange = action_menu_radio); ui_menuseparator(); ui_menuitem("Close"); diff -r 9fe8bff5c652 -r cae4af417424 ui/gtk/menu.c --- a/ui/gtk/menu.c Mon Dec 22 09:19:24 2025 +0100 +++ b/ui/gtk/menu.c Tue Dec 23 18:24:04 2025 +0100 @@ -525,22 +525,25 @@ } static void stateful_action_notify_group(UiMenuRadioGroup *group, UiInteger *i) { + int intval = ui_get(i); + UiEvent event; event.obj = group->obj; event.window = event.obj->window; event.document = event.obj->ctx->document; event.eventdata = NULL; event.eventdatatype = 0; - event.intval = (int)i->value; event.set = ui_get_setop(); CxIterator iter = cxListIterator(group->callbacks); cx_foreach(UiCallbackData *, cb, iter) { + event.intval = intval == iter.index; if(cb->callback) { cb->callback(&event, cb->userdata); } } + event.intval = intval; UiObserver *obs = i->observers; while(obs) { if(obs->callback) {