Mattias Gaertner wrote:
> Fixed in svn rev 26882.

OK. Here is the rest to activate the new hint windows. I can't find any
unwanted or faulty behavior anymore.

Bernd


Index: ide/codebrowser.pas
===================================================================
--- ide/codebrowser.pas	(Revision 26901)
+++ ide/codebrowser.pas	(Arbeitskopie)
@@ -215,6 +215,9 @@
     UnitFilterBeginsSpeedButton: TSpeedButton;
     UnitFilterContainsSpeedButton: TSpeedButton;
     UnitFilterEdit: TEdit;
+    procedure BrowseTreeViewMouseMove(Sender: TObject; Shift: TShiftState; X,
+      Y: Integer);
+    procedure FormDeactivate(Sender: TObject);
     procedure UseIdentifierInCurUnitMenuItemClick(Sender: TObject);
     procedure UsePkgInCurUnitMenuItemClick(Sender: TObject);
     procedure UsePkgInProjectMenuItemClick(Sender: TObject);
@@ -248,6 +251,7 @@
     procedure ShowPrivateCheckBoxChange(Sender: TObject);
     procedure ShowUnitsCheckBoxChange(Sender: TObject);
   private
+    FHintWindow: THintWindow;
     FIDEDescription: string;
     FOptions: TCodeBrowserViewOptions;
     FOptionsChangeStamp: integer;
@@ -333,6 +337,7 @@
     function GetCurPackageInSrcEditor: TLazPackage;
     procedure OpenTVNode(TVNode: TTreeNode);
     procedure UseUnitInSrcEditor(InsertIdentifier: boolean);
+    procedure CloseHintWindow;
   public
     procedure BeginUpdate;
     procedure EndUpdate;
@@ -433,6 +438,7 @@
 
 procedure TCodeBrowserView.FormCreate(Sender: TObject);
 begin
+  FHintWindow := nil;
   FOptions:=TCodeBrowserViewOptions.Create;
   
   FIDEDescription:=lisLazarusIDE;
@@ -2435,7 +2441,7 @@
   CurUnit: TCodeBrowserUnit;
   Node: TCodeBrowserNode;
   Line, Column: integer;
-  //BaseURL, HTMLHint: string;
+  BaseURL, HTMLHint: String;
 begin
   Result:='';
   if (TVNode=nil) or (TVNode.Data=nil) then exit;
@@ -2454,7 +2460,8 @@
       Node.CodePos.Code.AbsoluteToLineCol(Node.CodePos.P,Line,Column);
       if Line>0 then
         Result:=Result+' ('+IntToStr(Line)+','+IntToStr(Column)+')';
-      //GetCodeHelp(TVNode,BaseURL,HTMLHint);
+        if GetCodeHelp(TVNode, BaseURL, HTMLHint) then
+           Result := HTMLHint;
     end;
   end;
 end;
@@ -2533,7 +2540,8 @@
     if LazarusHelp.GetHintForSourcePosition(NewCodePos.Code.Filename,
       Point(NewCodePos.X,NewCodePos.Y),BaseURL,HTMLHint)<>shrSuccess then exit;
 
-    Result:=true;
+    if HTMLHint <> '' then
+       Result:=true;
   end;
 end;
 
@@ -2866,6 +2874,7 @@
   TVNode: TTreeNode;
   HintStr: String;
   MousePos: TPoint;
+  HintWinRect : TRect;
 begin
   //DebugLn(['TCodeBrowserView.BrowseTreeViewShowHint ',dbgs(HintInfo^.CursorPos)]);
   HintStr:='';
@@ -2875,9 +2884,29 @@
     HintStr:=GetTVNodeHint(TVNode);
     //DebugLn(['TCodeBrowserView.BrowseTreeViewShowHint HintStr="',HintStr,'"']);
   end;
-  HintInfo^.HintStr:=HintStr;
+
+  HintInfo^.HintStr:=''; // do not use the normal mechanism
+
+  // open a THintWindow with LazarusHelp instead
+  if hintstr = '' then
+     exit;
+  if csDestroying in ComponentState then exit;
+  if FHintWindow <> nil then
+    FHintWindow.Visible := false;
+  if FHintWindow = nil then
+    FHintWindow := THintWindow.Create(Self);
+  if LazarusHelp.CreateHint(FHintWindow, HintInfo^.HintPos, '', HintStr, HintWinRect) then
+      FHintWindow.ActivateHint(HintWinRect, HintStr);
 end;
 
+procedure TCodeBrowserView.CloseHintWindow;
+begin
+  if FHintWindow <> nil then begin
+    FHintWindow.Close;
+    FHintWindow := nil;
+  end;
+end;
+
 procedure TCodeBrowserView.CollapseAllPackagesMenuItemClick(Sender: TObject);
 begin
   ExpandCollapseAllNodesInTreeView(entPackage,false);
@@ -2970,6 +2999,17 @@
   UseUnitInSrcEditor(true);
 end;
 
+procedure TCodeBrowserView.BrowseTreeViewMouseMove(Sender: TObject;
+  Shift: TShiftState; X, Y: Integer);
+begin
+  CloseHintWindow;
+end;
+
+procedure TCodeBrowserView.FormDeactivate(Sender: TObject);
+begin
+  CloseHintWindow;
+end;
+
 { TCodeBrowserViewOptions }
 
 procedure TCodeBrowserViewOptions.SetModified(const AValue: boolean);
Index: ide/codebrowser.lfm
===================================================================
--- ide/codebrowser.lfm	(Revision 26901)
+++ ide/codebrowser.lfm	(Arbeitskopie)
@@ -8,6 +8,7 @@
   ClientHeight = 563
   ClientWidth = 623
   OnCreate = FormCreate
+  OnDeactivate = FormDeactivate
   OnDestroy = FormDestroy
   LCLVersion = '0.9.29'
   object ScopeGroupBox: TGroupBox
@@ -147,6 +148,7 @@
     ShowHint = True
     TabOrder = 2
     OnMouseDown = BrowseTreeViewMouseDown
+    OnMouseMove = BrowseTreeViewMouseMove
     OnShowHint = BrowseTreeViewShowHint
     Options = [tvoAutoItemHeight, tvoHideSelection, tvoKeepCollapsedNodes, tvoReadOnly, tvoShowButtons, tvoShowLines, tvoShowRoot, tvoToolTips, tvoThemedDraw]
   end
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to