diff --git a/Source/UI/Window/UITransMenuWnd.cpp b/Source/UI/Window/UITransMenuWnd.cpp index 2b74a1168..0418c865c 100644 --- a/Source/UI/Window/UITransMenuWnd.cpp +++ b/Source/UI/Window/UITransMenuWnd.cpp @@ -43,13 +43,12 @@ void UITransMenuWnd::OnLBtnDown(int x, int y) { void UITransMenuWnd::OnMouseMove(int x, int y) { const int margin = this->m_margin; const int previous = this->m_selected; - int selected = -1; - if (margin <= y) { - const unsigned count = this->m_items.size(); - if ((this->m_lineHeight + margin / 2) * count + margin >= static_cast(y)) { - const int cellHeight = (this->geometry.height - 2 * margin) / count; - selected = (y - margin) / cellHeight; - } + int selected; + if (margin <= y && (this->m_lineHeight + margin / 2) * this->m_items.size() + margin >= static_cast(y)) { + const int cellHeight = (this->geometry.height - 2 * margin) / this->m_items.size(); + selected = (y - margin) / cellHeight; + } else { + selected = -1; } this->m_selected = selected;