SourceEditor: Hide hint, when mouse moves (even if outside IDE, or IDE is not active). Issue #0022016

git-svn-id: trunk@37378 -
This commit is contained in:
martin 2012-05-21 15:59:20 +00:00
parent d4d543a5bb
commit a66b293fd8

View File

@ -662,6 +662,7 @@ type
// hintwindow stuff // hintwindow stuff
FHintWindow: THintWindow; FHintWindow: THintWindow;
FMouseHintTimer: TIdleTimer; FMouseHintTimer: TIdleTimer;
FMouseHideHintTimer: TTimer;
FHintMousePos: TPoint; FHintMousePos: TPoint;
procedure Activate; override; procedure Activate; override;
@ -706,6 +707,7 @@ type
procedure NotebookEndDrag(Sender, Target: TObject; X,Y: Integer); procedure NotebookEndDrag(Sender, Target: TObject; X,Y: Integer);
// hintwindow stuff // hintwindow stuff
procedure HintTimer(Sender: TObject); procedure HintTimer(Sender: TObject);
procedure HideHintTimer(Sender: TObject);
procedure OnApplicationUserInput(Sender: TObject; Msg: Cardinal); procedure OnApplicationUserInput(Sender: TObject; Msg: Cardinal);
procedure ShowSynEditHint(const MousePos: TPoint); procedure ShowSynEditHint(const MousePos: TPoint);
@ -5190,6 +5192,15 @@ begin
OnTimer := @HintTimer; OnTimer := @HintTimer;
end; end;
// Track mouse movements outside the IDE, if hint is visible
FMouseHideHintTimer := TTimer.Create(Self);
with FMouseHideHintTimer do begin
Name:=Self.Name+'_MouseHintHideTimer';
Interval := 500;
Enabled := False;
OnTimer := @HideHintTimer;
end;
// HintWindow // HintWindow
FHintWindow := THintWindow.Create(Self); FHintWindow := THintWindow.Create(Self);
with FHintWindow do begin with FHintWindow do begin
@ -5229,6 +5240,7 @@ begin
Application.RemoveOnUserInputHandler(@OnApplicationUserInput); Application.RemoveOnUserInputHandler(@OnApplicationUserInput);
FreeThenNil(FMouseHintTimer); FreeThenNil(FMouseHintTimer);
FreeThenNil(FMouseHideHintTimer);
FreeThenNil(FHintWindow); FreeThenNil(FHintWindow);
FreeAndNil(FNotebook); FreeAndNil(FNotebook);
@ -6735,6 +6747,7 @@ begin
FHintMousePos := Mouse.CursorPos; FHintMousePos := Mouse.CursorPos;
if LazarusHelp.CreateHint(FHintWindow,ScreenPos,BaseURL,AHint,HintWinRect) then if LazarusHelp.CreateHint(FHintWindow,ScreenPos,BaseURL,AHint,HintWinRect) then
FHintWindow.ActivateHint(HintWinRect,aHint); FHintWindow.ActivateHint(HintWinRect,aHint);
FMouseHideHintTimer.Enabled := True;
end; end;
procedure TSourceNotebook.HideHint; procedure TSourceNotebook.HideHint;
@ -6745,6 +6758,8 @@ begin
FMouseHintTimer.AutoEnabled := false; FMouseHintTimer.AutoEnabled := false;
FMouseHintTimer.Enabled:=false; FMouseHintTimer.Enabled:=false;
end; end;
if FMouseHideHintTimer <> nil then
FMouseHideHintTimer.Enabled := False;
if SourceCompletionTimer<>nil then if SourceCompletionTimer<>nil then
SourceCompletionTimer.Enabled:=false; SourceCompletionTimer.Enabled:=false;
if FHintWindow<>nil then begin if FHintWindow<>nil then begin
@ -6766,6 +6781,7 @@ var
Cur: TPoint; Cur: TPoint;
OkX, OkY: Boolean; OkX, OkY: Boolean;
begin begin
FMouseHideHintTimer.Enabled := False;
if (FHintWindow <> nil) and (FHintWindow.Visible) then begin if (FHintWindow <> nil) and (FHintWindow.Visible) then begin
Cur := Mouse.CursorPos; // Desktop coordinates Cur := Mouse.CursorPos; // Desktop coordinates
OkX := ( (FHintMousePos.x <= FHintWindow.Left) and OkX := ( (FHintMousePos.x <= FHintWindow.Left) and
@ -6802,8 +6818,10 @@ begin
(Cur.y < FHintMousePos.y + MaxJitter) and (Cur.y >= FHintWindow.Top - MaxJitter) (Cur.y < FHintMousePos.y + MaxJitter) and (Cur.y >= FHintWindow.Top - MaxJitter)
); );
if (OkX and OkY) then if (OkX and OkY) then begin
FMouseHideHintTimer.Enabled := True;
exit; exit;
end;
end; end;
HideHint; HideHint;
end; end;
@ -7759,6 +7777,17 @@ begin
ShowSynEditHint(MousePos); ShowSynEditHint(MousePos);
end; end;
procedure TSourceNotebook.HideHintTimer(Sender: TObject);
begin
if (FHintWindow = nil) or (not FHintWindow.Visible) then begin
FMouseHideHintTimer.Enabled := false;
exit;
end;
if ComparePoints(FHintMousePos, Mouse.CursorPos) <> 0 then
MaybeHideHint;
end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
procedure TSourceNotebook.OnApplicationUserInput(Sender: TObject; procedure TSourceNotebook.OnApplicationUserInput(Sender: TObject;
Msg: Cardinal); Msg: Cardinal);