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.
This commit is contained in:
ErrorFlynn 2020-02-03 02:49:20 -05:00 committed by GitHub
parent 6c547276ec
commit ff7fca9311
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -921,7 +921,25 @@ namespace nana
} }
else if (checks::option == item.style) 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; this->_m_close_all(); //means deleting this;