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.
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() )
Steps to reproduce the behaviour, please make them as detailed as possible.
For example:
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
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.![]()
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.![]()
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.![]()
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.![]()