wxMenuItem *wxMenu::DoRemove(wxMenuItem *item)
{
+ if ( m_startRadioGroup != -1 )
+ {
+ // Check if we're removing the item starting the radio group
+ if ( GetMenuItems().Item(m_startRadioGroup)->GetData() == item )
+ {
+ // Yes, we do, so reset its index as the next item added shouldn't
+ // count as part of the same radio group anyhow.
+ m_startRadioGroup = -1;
+ }
+ }
+
/*
// we need to find the items position in the child list
size_t pos;
DoHandleMenuEvent( wxevent );
}
-void wxMenu::HandleMenuOpened()
+void wxMenu::DoHandleMenuOpenedOrClosed(wxEventType evtType)
{
- wxMenuEvent wxevent(wxEVT_MENU_OPEN, 0, this);
+ // Popup menu being currently shown or NULL, defined in wincmn.cpp.
+ extern wxMenu *wxCurrentPopupMenu;
+
+ // Set the id to allow wxMenuEvent::IsPopup() to work correctly.
+ int menuid = this == wxCurrentPopupMenu ? wxID_ANY : 0;
+ wxMenuEvent wxevent(evtType, menuid, this);
DoHandleMenuEvent( wxevent );
}
+void wxMenu::HandleMenuOpened()
+{
+ DoHandleMenuOpenedOrClosed(wxEVT_MENU_OPEN);
+}
+
void wxMenu::HandleMenuClosed()
{
- wxMenuEvent wxevent(wxEVT_MENU_CLOSE, 0, this);
- DoHandleMenuEvent( wxevent );
+ DoHandleMenuOpenedOrClosed(wxEVT_MENU_CLOSE);
}
bool wxMenu::DoHandleMenuEvent(wxEvent& wxevent)
bool wxMenuBar::s_macAutoWindowMenu = true ;
WXHMENU wxMenuBar::s_macWindowMenuHandle = NULL ;
+const int firstMenuPos = 1; // to account for the 0th application menu on mac
+
void wxMenuBar::Init()
{
m_eventHandler = this;
{
wxCHECK_RET( IsAttached(), wxT("doesn't work with unattached menubars") );
- m_rootMenu->FindItemByPosition( pos )->Enable(enable);
+ m_rootMenu->FindItemByPosition(pos+firstMenuPos)->Enable(enable);
Refresh();
}
// wxMenuBar construction
// ---------------------------------------------------------------------------
-const int firstMenuPos = 1; // to account for the 0th application menu on mac
-
wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title)
{
wxMenu *menuOld = wxMenuBarBase::Replace(pos, menu, title);