how keep menu visible when checking/unchecking checkboxes

7 views
Skip to first unread message

danielc...@gmail.com

unread,
Dec 10, 2025, 9:21:11 AM (6 days ago) Dec 10
to fltk.general
Hi, this is staying visible at the first click, but hides at second.
The callback at second check isnt called..

void menu_cb(Fl_Widget* w, void* data) {
Fl_Menu_* menu = (Fl_Menu_*)w;
const Fl_Menu_Item* item = menu->mvalue();
const char* feature = (const char*)data;

// Detect if click was on the checkbox square (left ~25 pixels)
bool clicked_on_checkbox = (Fl::event_x() <= 25);
if (clicked_on_checkbox) {
item->popup(0, 0);
return;
}

// Normal click on text → normal behavior (close menu + your action)
printf("Activated feature %s (state = %d)\n", feature, item->value());
}


Thanks

danielc...@gmail.com

unread,
Dec 10, 2025, 9:32:38 AM (6 days ago) Dec 10
to fltk.general
Found the solution:

void menu_cb(Fl_Widget* w, void* data) {
Fl_Menu_Bar* menu = (Fl_Menu_Bar*)w;
const Fl_Menu_Item* item = menu->mvalue();
const char* feature = (const char*)data;

// Detect if click was on the checkbox square (left ~25 pixels)
bool clicked_on_checkbox = (Fl::event_x() <= 25);
if (clicked_on_checkbox) {
menu->play_menu(item);
return;
}

// Normal click on text → normal behavior (close menu + your action)
printf("Activated feature %s (state = %d)\n", feature, item->value());
}
Reply all
Reply to author
Forward
0 new messages