Don't duplicate same code twice in wxAuiToolBar::OnRightUp()

For unknown reasons we used exactly the same code for sending event with
valid and invalid tool ID instead of just setting a variable containing
the tool ID and then using it.

Fix this now.

No real changes.
This commit is contained in:
Vadim Zeitlin
2026-02-24 23:35:22 +01:00
parent 1806e40a45
commit 1b840d974d

View File

@@ -2873,26 +2873,24 @@ void wxAuiToolBar::OnRightUp(wxMouseEvent& evt)
wxAuiToolBarItem* hitItem;
hitItem = FindToolByPosition(evt.GetX(), evt.GetY());
int toolId;
if (m_actionItem && hitItem == m_actionItem)
{
wxAuiToolBarEvent e(wxEVT_AUITOOLBAR_RIGHT_CLICK, m_actionItem->m_toolId);
e.SetEventObject(this);
e.SetToolId(m_actionItem->m_toolId);
e.SetClickPoint(m_actionPos);
GetEventHandler()->ProcessEvent(e);
DoIdleUpdate();
toolId = m_actionItem->m_toolId;
}
else
{
// right-clicked on the invalid area of the toolbar
wxAuiToolBarEvent e(wxEVT_AUITOOLBAR_RIGHT_CLICK, -1);
e.SetEventObject(this);
e.SetToolId(-1);
e.SetClickPoint(m_actionPos);
GetEventHandler()->ProcessEvent(e);
DoIdleUpdate();
toolId = wxNOT_FOUND;
}
wxAuiToolBarEvent e(wxEVT_AUITOOLBAR_RIGHT_CLICK, toolId);
e.SetEventObject(this);
e.SetToolId(toolId);
e.SetClickPoint(m_actionPos);
GetEventHandler()->ProcessEvent(e);
DoIdleUpdate();
// reset member variables
m_actionPos = wxPoint(-1,-1);
m_actionItem = nullptr;