Sign in Join

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

Mailing lists / lazarus / 2011-04

TTreeView.OnItemClicked

6 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

19059: find-in-files unexpected jump to source
and
19142: TTreeView can't tell if an item was clicked, or if expansion '+' or background was clicked instead

Is it OK to implement a new event OnItemClick or OnNodeClick for TTreeView? It would be triggered only a node is clicked, not the '+' or background.

Juha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20110424/af36b552/attachment.html>

Reply by email

Mattias Gaertner
to Juha Manninen
19059: find-in-files unexpected jump to source and 19142: TTreeView can't tell if an item was clicked, or if expansion '+' or background was clicked instead

OnClick is for the whole control.
OnMouseDown/Up is for more details.

Is it OK to implement a new event OnItemClick or OnNodeClick for TTreeView? It would be triggered only a node is clicked, not the '+' or background.

Often the background should be included in the trigger area. And sometimes - as for example in the find in files dialog - you need to distinguish between single and multi click.
All this can be easily done with OnMouseDown/Up.

Mattias

Reply by email

Juha gmail
to Mattias Gaertner

Mattias Gaertner kirjoitti sunnuntai, 24. huhtikuuta 2011 02:19:03:

Show quoted text 8 lines
> Is it OK to implement a new event OnItemClick or OnNodeClick for > TTreeView? It would be triggered only a node is clicked, not the '+' or > background. Often the background should be included in the trigger area. And sometimes - as for example in the find in files dialog - you need to distinguish between single and multi click. All this can be easily done with OnMouseDown/Up.

Ok, it is _relatively_ easy but still not very intuitive. I guess 99% of code is only interested in clicked Nodes. Looking at your fix to TSearchResultsView, most of TreeViewMouseUp code is only for checking if a Node is left-clicked:

 var
   TV: TCustomTreeView;
   Node: TTreeNode;
 begin
   if ButtonmbLeft then exit;
   TV:=Sender as TCustomTreeView;
   Node:=TV.GetNodeAt(X,Y);
   if Node=nil then exit;
   if x<Node.DisplayTextLeft then exit;

...and then dealing with single/double click:

   if ([ssDouble,ssTriple,ssQuad]*Shift=[])
     and EnvironmentOptions.MsgViewDblClickJumps then exit;

In this case both single and double clicks need to be handled but typically only one of them.

So, I still think it is a good idea to have events OnNodeClicked and OnNodeDoubleClicked
with "Node: TTreeNode" parameter.

Juha

Reply by email

Mattias Gaertner
to Juha gmail
Show quoted text 12 lines
Mattias Gaertner kirjoitti sunnuntai, 24. huhtikuuta 2011 02:19:03: > > Is it OK to implement a new event OnItemClick or OnNodeClick for > > TTreeView? It would be triggered only a node is clicked, not the '+' or > > background. > > Often the background should be included in the trigger area. > And sometimes - as for example in the find in files dialog - you need > to distinguish between single and multi click. > All this can be easily done with OnMouseDown/Up. Ok, it is _relatively_ easy but still not very intuitive. I guess 99% of code is only interested in clicked Nodes.

I think your 99% is highly exaggerated.
There is only one place in the whole IDE and here it is not clear if with or without background (I would prefer with).

Show quoted text 17 lines
Looking at your fix to TSearchResultsView, most of TreeViewMouseUp code is only for checking if a Node is left-clicked: var TV: TCustomTreeView; Node: TTreeNode; begin if ButtonmbLeft then exit; TV:=Sender as TCustomTreeView; Node:=TV.GetNodeAt(X,Y); if Node=nil then exit; if x<Node.DisplayTextLeft then exit; ...and then dealing with single/double click: if ([ssDouble,ssTriple,ssQuad]*Shift=[]) and EnvironmentOptions.MsgViewDblClickJumps then exit;

There was a small mistake. The 'and' must be a '='.

Show quoted text 6 lines
In this case both single and double clicks need to be handled but typically only one of them. So, I still think it is a good idea to have events OnNodeClicked and OnNodeDoubleClicked with "Node: TTreeNode" parameter.

I still think they are hardly used.
If OnNodeClicked would support clicking via keyboard then it has a gain.

Mattias

Reply by email

Juha gmail
to Mattias Gaertner

How can you guys add notes to a resolved isue. For me it says: The action cannot be performed because issue '19059' is read-only

Anyway, the last comments in #19059 kind of prove my point. It is difficult and non-intuitive with the existing events. :)

Juha

Reply by email

Martin
to Juha gmail
Juha wrote
How can you guys add notes to a resolved isue. For me it says: The action cannot be performed because issue '19059' is read-only

Use "update" for the issue. It allows you to add a note....

I had the same question once, for a long time.....

Reply by email