wxASSERT_MSG( !item->IsSeparator() && !item->IsSubMenu(),
_T("can't click this item") );
- m_menu->ClickItem(item);
+ wxMenu* menu = m_menu;
// close all menus
DismissAndNotify();
+
+ menu->ClickItem(item);
}
void wxPopupMenuWindow::OpenSubmenu(wxMenuItem *item, InputMethod how)
void wxMenuBar::RefreshAllItemsAfter(size_t pos)
{
+ if ( !IsCreated() )
+ {
+ // no need to refresh if nothing is shown yet
+ return;
+ }
+
wxRect rect = GetItemRect(pos);
rect.width = GetClientSize().x - rect.x;
RefreshRect(rect);
wxCHECK_RET( pos != (size_t)-1,
_T("invalid item in wxMenuBar::RefreshItem") );
+ if ( !IsCreated() )
+ {
+ // no need to refresh if nothing is shown yet
+ return;
+ }
+
RefreshRect(GetItemRect(pos));
}
wxRect wxMenuBar::GetItemRect(size_t pos) const
{
wxASSERT_MSG( pos < GetCount(), _T("invalid menu bar item index") );
+ wxASSERT_MSG( IsCreated(), _T("can't call this method yet") );
wxRect rect;
rect.x =
}
else // right
{
- if ( ++currentNew == (int)count )
+ if ( ++currentNew == count )
currentNew = 0;
}
// that we pass 0 as width to position the menu exactly below the
// item, not to the right of it
wxRect rectItem = GetItemRect(m_current);
+
+ // Release mouse, because the menu will get the capture.
+ if (HasCapture())
+ ReleaseMouse();
+
m_menuShown->Popup(ClientToScreen(rectItem.GetPosition()),
wxSize(0, rectItem.GetHeight()),
selectFirst);
void wxMenuBar::OnDismiss()
{
- ReleaseCapture();
+ ReleaseMouse();
if ( m_current != -1 )
{