wxWidgets / wxWidgets

Cross-Platform C++ GUI Library
https://www.wxwidgets.org/
5.77k stars 1.7k forks source link

wxTipWindow mostly ignores BoundingRect #24495

Open wsu-cb opened 3 weeks ago

wsu-cb commented 3 weeks ago

Description

Bug description:

The wxTipWindow is not fully respecting its bounding rectangle.

Expected vs observed behaviour:

The wxTipWindow constructor has a (optional) rectBounds argument.

Expected: If the mouse leaves the rectBounds area, the wxTipWindow is supposed to close.

Observed: If the mouse leaves rectBounds but does not enter the wxTipWindow, the wxTipWindow does not close.

Patch or snippet allowing to reproduce the problem:

wxTipWindow-BoundingRect-bug.patch

To Reproduce:

Steps to reproduce the behaviour

  1. Apply the attached patch and run the dialogs sample
  2. Move the mouse cursor to roughly the middle of the dialogs sample
  3. Hit Ctrl+Shift+H to open the wxTipWindow
  4. The patch is written to set the rectBounds to the wxSize(5, 5) square around the initial cursor position. Move the cursor AWAY from the displayed wxTipWindow so that it leaves the initial wxSize(5, 5) square. No matter how far away the mouse is moved from its initial position, the wxTipWindow stays open.
  5. Now move the cursor over the wxTipWindow. The wxTipWindow closes.

The problem is that there is a wxEVT_MOTION handler in the wxTipWindow that checks the rectBounds, but if the mouse is not over wxTipWindow, the handler is never called.

Platform and version information

wsu-cb commented 3 weeks ago

I tried to modify the wxTipWindow implementation to wxEventHandler::Bind() a wxEVT_MOTION handler to the constructor's passed-in parent window to work around the problem. However, I discovered that the dialogs sample actually passes the MyFrame pointer rather than the MyCanvas pointer as the wxTipWindow's parent. Since the MyFrame is largely covered by the MyCanvas, the MyFrame didn't receive any wxEVT_MOTION events either, so this workaround didn't help at all. Is passing MyCanvas instead of MyFrame as the wxTipWindow parent an additional bug, or is there some need to do that? A quick test of passing MyCanvas instead of MyFrame didn't show any problems, and allowed this workaround to succeed.