Opened 2 years ago

Last modified 3 months ago

#14213 confirmed defect

Radio button groups don't work after deleting item from a menu under OS X

Reported by: shaurz Owned by:
Priority: normal Milestone:
Component: wxOSX (any toolkit) Version: dev-latest
Keywords: wxMenu wxMenuItem remove radiobutton Cc:
Blocked By: Blocking:
Patch: no

Description

When an item is deleted from a menu, radio button groups fail to work any more and it's possible to select multiple radio entries in the same group. See attached test case.

Attachments (2)

menu_radio_group_bug.py download (753 bytes) - added by shaurz 2 years ago.
Adjust-ranges-of-radio-button-groups.patch download (2.4 KB) - added by awi 4 months ago.
Adjust ranges of radio button groups.

Download all attachments as: .zip

Change History (8)

Changed 2 years ago by shaurz

comment:1 Changed 2 years ago by vadz

  • Keywords menu radio added
  • Status changed from new to confirmed

I can indeed reproduce this in the menu sample under MSW with this patch:

  • samples/menu/menu.cpp

    diff --git a/samples/menu/menu.cpp b/samples/menu/menu.cpp
    index 3c8f97d..233cad5 100644
    a b void MyFrame::ShowContextMenu(const wxPoint& pos) 
    10831083    else // normal case, shift not pressed 
    10841084    { 
    10851085        menu.Append(Menu_Help_About, wxT("&About")); 
     1086        menu.AppendRadioItem(Menu_Test_Radio1, "Radio 1"); 
     1087        menu.AppendRadioItem(Menu_Test_Radio2, "Radio 2"); 
     1088        menu.AppendRadioItem(Menu_Test_Radio3, "Radio 3"); 
     1089        menu.Delete(Menu_Help_About); 
     1090        menu.Check(Menu_Test_Radio3, true); 
     1091        PopupMenu(&menu, pos); 
     1092        return; 
     1093 
    10861094        menu.Append(Menu_Popup_Submenu, wxT("&Submenu"), CreateDummyMenu(NULL)); 
    10871095        menu.Append(Menu_Popup_ToBeDeleted, wxT("To be &deleted")); 
    10881096        menu.AppendCheckItem(Menu_Popup_ToBeChecked, wxT("To be &checked")); 

Don't have time to debug how/why exactly is it broken right now though...

comment:2 Changed 4 months ago by awi

  • Keywords wxMenu wxMenuItem remove radiobutton added; menu radio removed
  • Patch set
  • Version changed from 2.9.3 to dev-latest

Problems with selecting radio buttons when any item is removed from the menu are caused by the fact that indices of the reamining items (inluding radio buttons) have been changed due to this operation but ranges of the radio buttons groups are not updated.
Patch fixing this issue is attached (attachment:ticket:14213:Adjust-ranges-of-radio-button-groups.patch).

Changed 4 months ago by awi

Adjust ranges of radio button groups.

comment:3 Changed 3 months ago by vadz

  • Component changed from GUI-all to wxOSX (any toolkit)
  • Summary changed from Radio button groups don't work after deleting item from a menu (Windows and OS X) to Radio button groups don't work after deleting item from a menu under OS X

Thanks a lot for fixing this!

Unfortunately the bug is almost certainly still present in wxOSX. We really should reuse the same code there, wxMenuRadioItemsData is not platform-specific at all and it "just" needs to be extracted to some include/wx/private/menuradio.h and be used in both ports...

comment:4 Changed 3 months ago by VZ

In 76650:

Fix bug with removing items from menus with radio buttons in wxMSW.

Update the indices of the radio groups after removing an item from the menu.

See #14213.

comment:5 Changed 3 months ago by VZ

In 76656:

Fix bug with removing items from menus with radio buttons in wxMSW.

Update the indices of the radio groups after removing an item from the menu.

See #14213.

comment:6 Changed 3 months ago by vadz

  • Patch unset
Note: See TracTickets for help on using tickets.