From 5089cbc1ff694cbc110856b00c835ed3837de5b1 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 26 Aug 2025 00:26:55 +0200 Subject: [PATCH] Handle double clicks in the map as simple clicks This is much more useful than ignoring them as some clicks in a series of clicks could be unintentionally lost/ignored before. --- samples/stc/stctest.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/samples/stc/stctest.cpp b/samples/stc/stctest.cpp index 69d862aee1..a5ecbb007f 100644 --- a/samples/stc/stctest.cpp +++ b/samples/stc/stctest.cpp @@ -962,7 +962,9 @@ public: }); // Handle mouse events for dragging the visible zone indicator. - Bind(wxEVT_LEFT_DOWN, &wxStyledTextCtrlMap::OnLeftDown, this); + Bind(wxEVT_LEFT_DOWN, [this](wxMouseEvent& event) { + HandleMouseClick(event); + }); Bind(wxEVT_MOTION, [this](wxMouseEvent& event) { if ( event.LeftIsDown() && IsDragging() ) @@ -974,9 +976,10 @@ public: DoStopDragging(); }); - Bind(wxEVT_LEFT_DCLICK, [this](wxMouseEvent& WXUNUSED(event)) { - // Don't let Scintilla get the double click, even if we don't do - // anything with it ourselves. + Bind(wxEVT_LEFT_DCLICK, [this](wxMouseEvent& event) { + // Don't let Scintilla get the double click, handle it as a simple + // click instead. + HandleMouseClick(event); }); Bind(wxEVT_MOUSE_CAPTURE_LOST, [this](wxMouseCaptureLostEvent& WXUNUSED(event)) { @@ -1208,7 +1211,7 @@ private: return m_dragOffset != -1; } - void OnLeftDown(wxMouseEvent& event) + void HandleMouseClick(wxMouseEvent& event) { auto const posMouse = event.GetPosition(); auto const line = GetMapLineAtPoint(posMouse);