Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2010-04

TTreeView events OnCreateNodeClass and OnAddition

10 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Juha Manninen

Hi,

Delphi compatibility issue again. TTreeView is missing events: TTreeView.OnCreateNodeClass and
TTreeView.OnAddition

They don't exist in parent classes or anywhere in LCL. Is there any chance they will be implemented or should I change the program code to get around this problem?

Regards,
Juha

Reply by email

Andrew Haines
to Juha Manninen
Juha Manninen wrote
Hi, Delphi compatibility issue again. TTreeView is missing events: TTreeView.OnCreateNodeClass and

LCL has TTreeView.OnCustomCreateItem which may do what you want for this

TTreeView.OnAddition

Sorry I don't know.

They don't exist in parent classes or anywhere in LCL. Is there any chance they will be implemented or should I change the program code to get around this problem?

Regards,

Andrew

Reply by email

Juha Manninen
to Andrew Haines
Andrew Haines wrote
> Delphi compatibility issue again. TTreeView is missing events: > TTreeView.OnCreateNodeClass and LCL has TTreeView.OnCustomCreateItem which may do what you want for this

Now this may be a stupid question but what is the easiest way to use node class derived from TTreeNode, instead of TTreeNode itself?

In the program I try to port there is:

TViewNode = class(TTreeNode)
...

Then OnCreateNodeClass handler is used only to indicate the node class type:

  procedure TTreeViewIntegrator.tvModelCreateNodeClass(
    Sender:   TCustomTreeView; var NodeClass: TTreeNodeClass);
  begin
    NodeClass := TViewNode;
  end;

In OnCustomCreateItem handler I would need to actually create the node and take care of owner and parent or siblings or whatever.

Regards,
Juha

Reply by email

Mattias Gaertner
to Juha Manninen
Show quoted text 25 lines
Andrew Haines wrote: > > Delphi compatibility issue again. TTreeView is missing events: > > TTreeView.OnCreateNodeClass and > > LCL has TTreeView.OnCustomCreateItem which may do what you want for this Now this may be a stupid question but what is the easiest way to use node class derived from TTreeNode, instead of TTreeNode itself? In the program I try to port there is: TViewNode = class(TTreeNode) ... Then OnCreateNodeClass handler is used only to indicate the node class type: procedure TTreeViewIntegrator.tvModelCreateNodeClass( Sender: TCustomTreeView; var NodeClass: TTreeNodeClass); begin NodeClass := TViewNode; end; In OnCustomCreateItem handler I would need to actually create the node and take care of owner and parent or siblings or whatever.

The easiest way would be a simple property NodeClass: TTreeNodeClass.

For Delphi compatibility I added OnCreateNodeClass.

Mattias

Reply by email

Mattias Gaertner
to Juha Manninen: Where should I add that property? if nodes are created with TreeView.Items.AddObject(...)…
Show quoted text 6 lines
Mattias Gaertner wrote: > The easiest way would be a simple property NodeClass: TTreeNodeClass. Where should I add that property? if nodes are created with TreeView.Items.AddObject(...) or similar method, there is no way to define the node type.

It is just my humble opinion that instead of adding a published event property it would be simpler to have a property NodeClass: TTreeNodeClass.
But since Delphi already defined an event, we use the event. So no need for a simple property.

Mattias

Reply by email

Juha Manninen
to Mattias Gaertner: On Sat, 1 May 2010 17:42:09 +0300 The easiest way would be a simple property NodeClass:…
Mattias Gaertner wrote
The easiest way would be a simple property NodeClass: TTreeNodeClass.

Where should I add that property? if nodes are created with TreeView.Items.AddObject(...)
or similar method, there is no way to define the node type.

For Delphi compatibility I added OnCreateNodeClass.

Thanks.
Now there is OnAddition waiting in bug tracker. See: issue #16383: Implemented TTreeview.OnAddition event

Regards,
Juha

Reply by email

Juha Manninen
to Mattias Gaertner: On Sat, 1 May 2010 20:00:51 +0300 It is just my humble opinion that instead of adding a…
Mattias Gaertner wrote 5 lines
It is just my humble opinion that instead of adding a published event property it would be simpler to have a property NodeClass: TTreeNodeClass. But since Delphi already defined an event, we use the event. So no need for a simple property.

Ok, I understand now. I would be happy with either of the systems. Delphi programs would be quite easy to convert with the property system. On the other hand, the published event is not too complicated either. It is good now.

Juha

Reply by email

José Mejuto
to Mattias Gaertner: On Sat, 1 May 2010 20:00:51 +0300 It is just my humble opinion that instead of adding a…

Hello Lazarus-List,

Saturday, May 1, 2010, 6:50:52 PM, you wrote:

MG> It is just my humble opinion that instead of adding a published event MG> property it would be simpler to have a property NodeClass: MG> TTreeNodeClass.
MG> But since Delphi already defined an event, we use the event. So no need MG> for a simple property.

IMHO if you have a simple property it would be quite complex to use different TreeNode types in the same TreeView, just like a TreeView with files and folders, each one with its derived TreeNode class.

Best regards, Jos?

Reply by email

Mattias Gaertner
to José Mejuto
Show quoted text 13 lines
Hello Lazarus-List, Saturday, May 1, 2010, 6:50:52 PM, you wrote: MG> It is just my humble opinion that instead of adding a published event MG> property it would be simpler to have a property NodeClass: MG> TTreeNodeClass. MG> But since Delphi already defined an event, we use the event. So no need MG> for a simple property. IMHO if you have a simple property it would be quite complex to use different TreeNode types in the same TreeView, just like a TreeView with files and folders, each one with its derived TreeNode class.
TV.NodeClass:=TFileTreeNode;
TV.Items.Add(nil,'');
TV.NodeClass:=TDirectoryTreeNode;
TV.Items.Add(nil,'');

Does not look complicated to me.

Mattias

Reply by email

José Mejuto
to Mattias Gaertner

Hello Lazarus-List,

Sunday, May 2, 2010, 12:29:49 AM, you wrote:

MG> TV.NodeClass:=TFileTreeNode;
MG> TV.Items.Add(nil,'');
MG> TV.NodeClass:=TDirectoryTreeNode;
MG> TV.Items.Add(nil,'');
MG> Does not look complicated to me.

For sure not very complicated :) My mind was a bit ofuscated as I was playing with threads, and from a thread point of view an event seems more easy, but as threads and LCL are not good friends...

Maybe it was added thinking in a class creator based in a data pointer instead a sequenced code, but anyway any of both seems quite simple.

Best regards, Jos?

Reply by email