AUI Toolbar right click on tool doesn't find tool id (Issue #26242)

11 views
Skip to first unread message

Ian McInerney

unread,
Feb 24, 2026, 2:38:54 PM (yesterday) Feb 24
to wx-...@googlegroups.com, Subscribed
imciner2 created an issue (wxWidgets/wxWidgets#26242)

Description

Bug description:

Originally seen in KiCad https://gitlab.com/kicad/code/kicad/-/issues/23231.

When you right-click on a toolbar item that is only an image, the left side of the image reports the correct tool ID in the event, while the right side of the image reports a -1 tool ID in the event.

The expected behavior is that the entire toolbar image gives the tool ID when right-clicked anywhere in its rectangle.

Patch or snippet allowing to reproduce the problem:

This can be seen in the AUI demo with this small modification.

diff --git a/samples/aui/auidemo.cpp b/samples/aui/auidemo.cpp
index 3be861fef4..54bf62471f 100644
--- a/samples/aui/auidemo.cpp
+++ b/samples/aui/auidemo.cpp
@@ -171,6 +171,7 @@ private:
     void OnCreateSizeReport(wxCommandEvent& evt);
     void OnChangeContentPane(wxCommandEvent& evt);
     void OnDropDownToolbarItem(wxAuiToolBarEvent& evt);
+    void OnToolbarItemRightClick(wxAuiToolBarEvent& evt);
     void OnCreatePerspective(wxCommandEvent& evt);
     void OnCopyLayout(wxCommandEvent& evt);
     void OnPasteLayout(wxCommandEvent& evt);
@@ -928,6 +929,7 @@ MyFrame::MyFrame(wxWindow* parent,
     tb1->SetCustomOverflowItems(prependItems, appendItems);
     tb1->Realize();
 
+    Connect( wxEVT_AUITOOLBAR_RIGHT_CLICK, wxAuiToolBarEventHandler( MyFrame::OnToolbarItemRightClick ), nullptr, tb1 );
 
     wxAuiToolBar* tb2 = new wxAuiToolBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize,
                                          wxAUI_TB_DEFAULT_STYLE | wxAUI_TB_OVERFLOW | wxAUI_TB_HORIZONTAL);
@@ -2484,6 +2486,12 @@ void MyFrame::OnDropDownToolbarItem(wxAuiToolBarEvent& evt)
 }
 
 
+void MyFrame::OnToolbarItemRightClick(wxAuiToolBarEvent& evt)
+{
+    wxLogMessage("Tool: %d", evt.GetToolId());
+    wxLogMessage("Location: (%d,%d)", evt.GetItemRect().x, evt.GetItemRect().y);
+}
+
 void MyFrame::OnTabAlignment(wxCommandEvent &evt)
 {
     for ( const auto& pane : m_mgr.GetAllPanes() )

To Reproduce:

Steps to reproduce the behaviour, please make them as detailed as possible.
For example:

  1. Apply the above patch
  2. Try right-clicking on the left vertical toolbar (with the error image).
  3. See that the left side of the toolbar item images will report a Tool ID in the message box, while the right side will report -1 as the Tool ID in the message box.

Platform and version information

  • wxWidgets version you use: Master (fresh build) and 3.2.8 (Fedora build)
  • wxWidgets port you use: wxGTK
  • OS and its version: Fedora 42
    • GTK version: 3.24.49
    • Which GDK backend is used: X11
    • Desktop environment : MATE
    • Current theme:


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26242@github.com>

VZ

unread,
Feb 24, 2026, 2:52:33 PM (yesterday) Feb 24
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26242)

Thanks, I can see this (under Wayland too FWIW, but also in wxMSW), will take a look.

Location is always invalid for me BTW, also in both ports.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26242/3954379827@github.com>

Ian McInerney

unread,
Feb 24, 2026, 3:00:20 PM (yesterday) Feb 24
to wx-...@googlegroups.com, Subscribed
imciner2 left a comment (wxWidgets/wxWidgets#26242)

Yea, I think that item rect isn't being assigned at all on a right-click event, instead it is supposed to assign to the click point. I had quickly made the reproducer again, so missed that minor detail. If you change the message in the patch to instead use GetClickPoint(), then you can see the location has the same problem (it is only valid on the left-side of the image).


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26242/3954414590@github.com>

VZ

unread,
Feb 24, 2026, 3:01:12 PM (yesterday) Feb 24
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26242)

I see the problem, it's a wrong test for overflow.

I'll fix it in master and backport to 3.2.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26242/3954418531@github.com>

VZ

unread,
Feb 24, 2026, 5:53:27 PM (yesterday) Feb 24
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26242)

OK, I've got a bit carried away, but the fix for this particular bug is just in the first commit of the linked PR.

If you can, please test the entire PR to check that it doesn't introduce any regressions.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/issues/26242/3955182001@github.com>

Reply all
Reply to author
Forward
0 new messages