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
This commit is contained in:
Vadim Zeitlin 2008-03-03 01:58:39 +00:00
parent 0fb0db5c95
commit 95d3881fed

View File

@ -1672,7 +1672,29 @@ void wxWindowBase::OnHelp(wxHelpEvent& event)
wxHelpProvider *helpProvider = wxHelpProvider::Get(); wxHelpProvider *helpProvider = wxHelpProvider::Get();
if ( helpProvider ) 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 // skip the event.Skip() below
return; return;