X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a756f210019dd5b51331b7181c816d3882146a30..e531b73f8910b3dcb2457bb74eb3723f2d516f5f:/src/univ/menu.cpp diff --git a/src/univ/menu.cpp b/src/univ/menu.cpp index ac728688b9..a880d50037 100644 --- a/src/univ/menu.cpp +++ b/src/univ/menu.cpp @@ -352,14 +352,9 @@ void wxPopupMenuWindow::ChangeCurrent(wxMenuItemList::Node *node) wxMenuItemList::Node *wxPopupMenuWindow::GetPrevNode() const { - wxMenuItemList::Node *node = m_nodeCurrent; - if ( !node ) - { - // start from the end if no current item - node = m_menu->GetMenuItems().GetLast(); - } - - return GetPrevNode(node); + // return the last node if there had been no previously selected one + return m_nodeCurrent ? GetPrevNode(m_nodeCurrent) + : m_menu->GetMenuItems().GetLast(); } wxMenuItemList::Node * @@ -380,14 +375,9 @@ wxPopupMenuWindow::GetPrevNode(wxMenuItemList::Node *node) const wxMenuItemList::Node *wxPopupMenuWindow::GetNextNode() const { - wxMenuItemList::Node *node = m_nodeCurrent; - if ( !node ) - { - // start from the beginning if no current item - node = m_menu->GetMenuItems().GetFirst(); - } - - return GetNextNode(node); + // return the first node if there had been no previously selected one + return m_nodeCurrent ? GetNextNode(m_nodeCurrent) + : m_menu->GetMenuItems().GetFirst(); } wxMenuItemList::Node * @@ -672,7 +662,7 @@ bool wxPopupMenuWindow::ProcessLeftDown(wxMouseEvent& event) wxPopupMenuWindow *win = menu->m_popupMenu; wxCHECK_MSG( win, FALSE, _T("parent menu not shown?") ); - + pos = ClientToScreen(pos); if ( win->GetMenuItemFromPoint(win->ScreenToClient(pos)) ) { @@ -1269,7 +1259,7 @@ void wxMenu::Popup(const wxPoint& pos, const wxSize& size, bool selectFirst) { m_popupMenu->SelectFirst(); } - + // the geometry might have changed since the last time we were shown, so // always resize m_popupMenu->SetClientSize(GetGeometryInfo().GetSize()); @@ -1847,6 +1837,7 @@ int wxMenuBar::GetMenuFromPoint(const wxPoint& pos) const void wxMenuBar::SelectMenu(size_t pos) { SetFocus(); + wxLogTrace(_T("mousecapture"), _T("Capturing mouse from wxMenuBar::SelectMenu")); CaptureMouse(); DoSelectMenu(pos); @@ -1935,6 +1926,7 @@ void wxMenuBar::OnLeftDown(wxMouseEvent& event) } else // on item { + wxLogTrace(_T("mousecapture"), _T("Capturing mouse from wxMenuBar::OnLeftDown")); CaptureMouse(); // show it as selected @@ -2296,7 +2288,10 @@ void wxMenuBar::OnDismissMenu(bool dismissMenuBar) void wxMenuBar::OnDismiss() { if ( GetCapture() ) + { + wxLogTrace(_T("mousecapture"), _T("Releasing mouse from wxMenuBar::OnDismiss")); GetCapture()->ReleaseMouse(); + } if ( m_current != -1 ) {