What event do I need to write in my wxWidgets program so that I can track mouse dragging. I mean hold down the left mouse button and track the movement while it is pressed.
What event do I need to write in my wxWidgets program so that I can track mouse dragging. I mean hold down the left mouse button and track the movement while it is pressed.
Perhaps surprisingly, this is not such a simple task. You may look at the implementation of wxMouseEventsManager to see an example of working code doing it, but the main point is that you need to capture the mouse on button press, in order to follow its movement even if it exits the window, and then you need to also react to wxEVT_MOUSE_CAPTURE_LOST events to know when the capture is forcibly broken.
Bind(wxEVT_MOTION, [&](wxMouseEvent& event) {
if (event.Dragging()) {
if (event.LeftIsDown()) {
// code
}
}
});