From ff7fca93110ebf07dd134d982008fcf9b9092508 Mon Sep 17 00:00:00 2001 From: ErrorFlynn Date: Mon, 3 Feb 2020 02:49:20 -0500 Subject: [PATCH] fix: submenu option items unresponsive to clicks When the user opens a submenu containing items with the style `menu::checks::option` and clicks an option, the radio button logic doesn't work. This bug was discovered and fixed by nanapro.org forum user "huycan" (I'm just submitting the PR). See this forum post: http://nanapro.org/en-us/forum/index.php?u=/topic/1256/ggleave-a-menu-open As mentioned in more detail in the forum post linked above, my understanding of why this happens is that `menu_builder::checked` fails because the `menu_window` of the submenu is created with the `menu_builder` object used by the parent menu. --- source/gui/widgets/menu.cpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/source/gui/widgets/menu.cpp b/source/gui/widgets/menu.cpp index 26b21812..750e8422 100644 --- a/source/gui/widgets/menu.cpp +++ b/source/gui/widgets/menu.cpp @@ -921,7 +921,25 @@ namespace nana } else if (checks::option == item.style) { - get_drawer_trigger().mbuilder().checked(active, true); + if(active > 0) + { + do { + if(menu->items[--active]->flags.splitter) + { + ++active; + break; + } + } while(active > 0); + } + while(active < menu->items.size()) + { + menu_item_type &el = *(menu->items[active++]); + if(el.flags.splitter) + break; + if(checks::option == el.style) + el.flags.checked = false; + } + item.flags.checked = true; } this->_m_close_all(); //means deleting this;