TreeView Default editor-how to access it for QUE_BANNER text ? lazarus / 31-LCL ---------------------------------------------------------------------- jamie · 2019-09-15 15:41 The default editor you get for the Cells of a node when in editing mode, I need to set the QUE_BANNER text or in the case of a TEDIT the HintText.    Unless I am overlooking something I don't see a Accessible property in the TreeView control to get at the editor object itself nor do I see the option property?   Am I blind ? ---------------------------------------------------------------------- jamie · 2019-09-15 16:11 It seems I can do this but it isn't Cross platform .. TVM_GETEDITCONTROL returns the handle then I can use the SendMessage(….. to set the Que_Banner text..   Shouldn't there be a property in there for this that works on the other widgets too ? ---------------------------------------------------------------------- ASerge · 2019-09-15 19:24 Quote from: jamie on September 15, 2019, 05:41:14 pm  Am I blind ? It's protected. Helper can help: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i type  TTreeViewHelper = class helper for TTreeView  public    procedure SetCueBanner(const AText: string);  end; procedure TForm1.TreeView1Editing(Sender: TObject; Node: TTreeNode; var AllowEdit: Boolean);begin  TreeView1.SetCueBanner('Test');end; procedure TTreeViewHelper.SetCueBanner(const AText: string);begin  if Assigned(FEditor) then    FEditor.TextHint := AText;end; ---------------------------------------------------------------------- jamie · 2019-09-15 21:24 Ok, I can try that. But why is that protected ? Wouldn't you think that would be a good feature to expose? EDIT:   Back again, Well it seems there is a reason why it's not exposed. Cause it does not work..     FEditor is always NIL, Most likely because windows has its own editor for this.  I am sure it works in the other Widget sets since they most likely need to implement the editor.  If it works in the other widgets then maybe a work around for all can be made somehow ?   I guess it would have to be in the Interface code so the base code will have no conditions in it. EDIT 2  back again, it seems I spoke too soon, it does not work on the first go around. the editor is late coming in. I'll have to see if I can figure that out.     It seems the editor isn't yet functional before the OnEditing is called. ---------------------------------------------------------------------- jamie · 2019-09-15 22:42 Ok, I found the problem area in "treeview.inc" at ~3367 .. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TCustomTreeView.BeginEditing(ANode: TTreeNode);var  ARect: TRect;begin  //DebugLn(['TCustomTreeView.BeginEditing tvsIsEditing=',tvsIsEditing in FStates,' Selected=',Selected<>nil]);  if (tvsIsEditing in FStates) or (ANode=nil) then exit;   // EDITOR NEEDS to be created here!   <<< Please NOTE   if (not CanEdit(ANode)) or (not ANode.Visible) then exit;  // if we are asked to edit another node while one is already being edited then  // stop editing that node  if FEditingItem <> nil then    EndEditing;  FEditingItem := ANode;  // make node visible (this will cancel editing, so call this first)  EnsureNodeIsVisible(ANode);   Include(FStates,tvsIsEditing);  if FEditor=nil then begin  // Editor should not be created here, too late..!     FEditor:=TEdit.Create(Self);    FEditor.OnEditingDone:=@EditorEditingDone;    FEditor.OnKeyDown:=@EditorKeyDown;  end;  ARect:=Rect(Max(BorderWidth,ANode.DisplayTextLeft),ANode.Top- ScrolledTop,              ClientWidth-BorderWidth,ANode.Bottom- ScrolledTop);  FEditor.BoundsRect:=ARect;  FEditor.AnchorParallel(akLeft,ARect.Left,Self);  FEditor.AnchorParallel(akRight,BorderWidth,Self);  FEditor.Visible:=true;  FEditor.Parent:=Self;  FEditor.Text:=ANode.Text;  FEditor.SelectAll;  FEditor.SetFocus;end;                           Please refer to lines #8 and #20 ---------------------------------------------------------------------- jamie · 2019-09-15 23:07 I wrote a Class over ride locally instead so I could override the beginEditing. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i TTreeView = Class(ComCtrls.TTreeView)  Procedure SetQueBanner(Const AText:String);  Procedure BeginEditing(ANode:TTreeNode); Override;end;   implementation {$R *.lfm} Procedure TTreeView.BeginEditing(ANode:TTreeNode);BeginIf Feditor = Nil ThenBegin FEditor:=TEDIT.Create(Self);//Editor must be created early..  FEditor.OnEditingDone:=@EditorEditingDone; FEditor.OnKeyDown:=@Editor KeyDown;End; Inherited BeginEditing(Anode);                                                                                                      End;           and the rest is as you original suggested but with using a class instead, because I was unable to override the method with a helper.   This now works, maybe we can suggest it to be fixed in the next release and also add the HintText Property ? ---------------------------------------------------------------------- ASerge · 2019-09-16 20:18 Quote from: jamie on September 15, 2019, 11:24:43 pm back again, it seems I spoke too soon, it does not work on the first go around. the editor is late coming in. I'll have to see if I can figure that out.   It seems the editor isn't yet functional before the OnEditing is called. Yeah, and I don't see what the problem is? ---------------------------------------------------------------------- jamie · 2019-09-16 20:41 The problem is the first time you go into edit mode and need to set the Editor.hintText the editor is NIL if you are trying to do this via the OnEditing event.  The Event is called before the TEDIT is created in the background so the first time you select editing there is a NIL editor so it never gets the chance to set the HintText inside the OnEditing Event.  Once the editor has been created it works ok but you miss the first go around.  if you look above as to what I did you can see the issue and how I worked around it.  Simply put, the Editor is being created too late in the BeginEditing event..  I showed the code as it is now in "Treeview.inc" at line #3367 or there abouts, and I also showed the comment about what needs to be done..  I can put this in as a fix request but I know it will go NO WHERE>  I can supply an example test app of the problem if you wish? ---------------------------------------------------------------------- ASerge · 2019-09-17 17:13 Quote from: jamie on September 16, 2019, 10:41:06 pmThe problem is the first time you go into edit mode and need to set the Editor.hintText the editor is NIL if you are trying to do this via the OnEditing event. Okay, thanks. So my example only works the second time. I suggest to make feature request in bugtracker, to add a method that will create FEditor unconditionally. ---------------------------------------------------------------------- jamie · 2019-09-19 22:17 Ok, his is the source file I will  present as a concept. Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i {$mode objfpc}{$H+}{$ModeSwitch TypeHelpers} interface uses  Windows, SysUtils, Forms, Controls, Graphics, Dialogs, ComCtrls, StdCtrls, Classes; type   { TForm1 }  TTreeView = class(ComCtrls.TTreeView)      {Local class override to correct issues }    procedure SetQueBanner(const AText: string);    procedure BeginEditing(ANode: TTreeNode); override;  end;   TForm1 = class(TForm)    TreeView1: TTreeView;    procedure TreeView1Editing(Sender: TObject; Node: TTreeNode;      var AllowEdit: boolean);  private   public   end; var  Form1: TForm1; implementation {$R *.lfm}procedure TTreeView.BeginEditing(ANode: TTreeNode);begin  if Feditor = nil then  begin    FEditor := TEDIT.Create(Self);//Editor must be created early..    FEditor.OnEditingDone := @EditorEditingDone;    FEditor.OnKeyDown := @EditorKeyDown;  end;  inherited BeginEditing(Anode);end; procedure TtreeView.SetQueBanner(const AText: string);begin  if Assigned(Feditor) then    Feditor.TextHint := AText;end; { TForm1 } procedure TForm1.TreeView1Editing(Sender: TObject; Node: TTreeNode;  var AllowEdit: boolean);begin  {Line@ ~3367 in TreeView.inc creates the editor too late }  {BeginEditng Method is overriden to correct for this }  {just to demo the effects of the correction}  TreeView1.SetQueBanner('Field Can not be empty');end; end.