Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

TElXTreeCell: cell control eventhandlers

Why not to expose cell control events through tree events?
It's strange for me that nobody did it before:

procedure TElXCellStyleAncestor.SetControl(newValue: TElXCellControl);
var
  LItem: TElXTreeItem;
  //<abb2015>
  HOwner : THCustomElXTree;
  //</abb2015>
//  LControl: TElXCellControl;
begin
  if (FControl <> newValue) then
  begin
    if Assigned(FControl) then begin
      LItem := TElXTreeItem(FItem);
      if Assigned(LItem) and Assigned(LItem.Owner) and
      (THCustomElXTree(LItem.Owner).VirtualityLevel = vlNone)
      then
        FControl.Destroy;
    end;
    FControl := newValue;
    if Assigned(FControl) then
    begin
      FControl.FOwner := Self;
      //<abb2015>
      LItem := TElXTreeItem(FItem);
      if Assigned(LItem) and Assigned(LItem.Owner) then
      begin
        HOwner := THCustomElXTree(LItem.Owner);
        if HOwner.VirtualityLevel = vlNone then
        begin
          FControl.OnClick := HOwner.OnCtlClick;
          FControl.OnDblClick := HOwner.OnCtlDblClick;
          FControl.OnMouseDown := HOwner.OnCtlMouseDown;
          FControl.OnMouseMove := HOwner.OnCtlMouseMove;
          FControl.OnMouseUp := HOwner.OnCtlMouseUp;
        end;
      end;
      //</abb2015>
    end;
    if not FIsUpdating then
      Update;
  end;
end;

Why should I assign these eventhandlers manually (in runtime), when I crete a cell control like checkbox? Creating cell controls for newly created tree items, I even not always know what event handler to use, because tree population might be done even in a separate unit, where none of designtime eventhandlers are accessible (just my case). Now I can have only one TElXTree reference, as argument, to populate tree content from a file, e.g. XML.

It would be great to add such little but very useful improvement.

Bye.

Comments

Sign In or Register to comment.