From 95d3881fed716e5d0f3ac70a693f8c8176954106 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 3 Mar 2008 01:58:39 +0000 Subject: [PATCH] position help windows shown when Shift-F1 is pressed near the window and not at the mouse position unless the mouse is over the window (this avoids showing the tooltip in the opposite corner of the screen) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52271 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/wincmn.cpp | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index a9e3999fcc..6b80b11927 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -1672,7 +1672,29 @@ void wxWindowBase::OnHelp(wxHelpEvent& event) wxHelpProvider *helpProvider = wxHelpProvider::Get(); if ( helpProvider ) { - if ( helpProvider->ShowHelpAtPoint(this, event.GetPosition(), event.GetOrigin()) ) + wxPoint pos = event.GetPosition(); + const wxHelpEvent::Origin origin = event.GetOrigin(); + if ( origin == wxHelpEvent::Origin_Keyboard ) + { + // if the help event was generated from keyboard it shouldn't + // appear at the mouse position (which is still the only position + // associated with help event) if the mouse is far away, although + // we still do use the mouse position if it's over the window + // because we suppose the user looks approximately at the mouse + // already and so it would be more convenient than showing tooltip + // at some arbitrary position which can be quite far from it + const wxRect rectClient = GetClientRect(); + if ( !rectClient.Contains(ScreenToClient(pos)) ) + { + // position help slightly under and to the right of this window + pos = ClientToScreen(wxPoint( + 2*GetCharWidth(), + rectClient.height + GetCharHeight() + )); + } + } + + if ( helpProvider->ShowHelpAtPoint(this, pos, origin) ) { // skip the event.Skip() below return;