Ensure that a wxMenuItem's parent menu is updated if it is removed
from one and added to another menu. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21027 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -49,6 +49,7 @@ public:
|
|||||||
|
|
||||||
// the menu we're in
|
// the menu we're in
|
||||||
wxMenu *GetMenu() const { return m_parentMenu; }
|
wxMenu *GetMenu() const { return m_parentMenu; }
|
||||||
|
void SetMenu(wxMenu* menu) { m_parentMenu = menu; }
|
||||||
|
|
||||||
// get/set id
|
// get/set id
|
||||||
void SetId(int itemid) { m_id = itemid; }
|
void SetId(int itemid) { m_id = itemid; }
|
||||||
|
@@ -319,6 +319,7 @@ bool wxMenuBase::DoAppend(wxMenuItem *item)
|
|||||||
wxCHECK_MSG( item, FALSE, wxT("invalid item in wxMenu::Append()") );
|
wxCHECK_MSG( item, FALSE, wxT("invalid item in wxMenu::Append()") );
|
||||||
|
|
||||||
m_items.Append(item);
|
m_items.Append(item);
|
||||||
|
item->SetMenu((wxMenu*)this);
|
||||||
if ( item->IsSubMenu() )
|
if ( item->IsSubMenu() )
|
||||||
{
|
{
|
||||||
AddSubMenu(item->GetSubMenu());
|
AddSubMenu(item->GetSubMenu());
|
||||||
@@ -352,6 +353,7 @@ bool wxMenuBase::DoInsert(size_t pos, wxMenuItem *item)
|
|||||||
wxCHECK_MSG( node, FALSE, wxT("invalid index in wxMenu::Insert()") );
|
wxCHECK_MSG( node, FALSE, wxT("invalid index in wxMenu::Insert()") );
|
||||||
|
|
||||||
m_items.Insert(node, item);
|
m_items.Insert(node, item);
|
||||||
|
item->SetMenu((wxMenu*)this);
|
||||||
if ( item->IsSubMenu() )
|
if ( item->IsSubMenu() )
|
||||||
{
|
{
|
||||||
AddSubMenu(item->GetSubMenu());
|
AddSubMenu(item->GetSubMenu());
|
||||||
@@ -380,6 +382,7 @@ wxMenuItem *wxMenuBase::DoRemove(wxMenuItem *item)
|
|||||||
m_items.DeleteNode(node);
|
m_items.DeleteNode(node);
|
||||||
|
|
||||||
// item isn't attached to anything any more
|
// item isn't attached to anything any more
|
||||||
|
item->SetMenu((wxMenu *)NULL);
|
||||||
wxMenu *submenu = item->GetSubMenu();
|
wxMenu *submenu = item->GetSubMenu();
|
||||||
if ( submenu )
|
if ( submenu )
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user