Recent

Author Topic: TreeView truncating my Node Captions why ?  (Read 6393 times)

Weitentaaal

  • Hero Member
  • *****
  • Posts: 516
  • Weitental is a very beautiful garbage depot.
TreeView truncating my Node Captions why ?
« on: June 07, 2021, 03:02:05 pm »
Hello :)

So my Attached Picture and the Caption should describe my Problem.
Any1 got an Idea ?

Thanks in advice :)
« Last Edit: June 07, 2021, 03:04:17 pm by Weitentaaal »

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: TreeView truncating my Node Captions why ?
« Reply #1 on: June 07, 2021, 05:53:00 pm »
Is this the standard LCL TTreeview? AFAIK, it has no immediate built-in checkbox support. And in the LCL TTreeView I do not see this issue. I am confused...

Or are you talking of VirtualTreeView? It has a multi-column mode which works with several columns, like in a StringGrid. If you entered this and your node text exceeds the width of the 0-th column, it looks exactly like in your screenshot.

Moreover, your TreeView screenshot shows wrapped node text in two lines. This is also no standard behaviour. You must be using custom-painting. But without seeing your code, nobody can solve your issue.
« Last Edit: June 07, 2021, 06:02:57 pm by wp »

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: TreeView truncating my Node Captions why ?
« Reply #2 on: June 07, 2021, 11:44:20 pm »
I know. But the standard TTreeView does not show ellipses even for long text, and it does not show checkboxes and it does not show multi-line nodes. So, the user musts do some custom-painting, and without seeing this code there's nothing that we can do.

Weitentaaal

  • Hero Member
  • *****
  • Posts: 516
  • Weitental is a very beautiful garbage depot.
Re: TreeView truncating my Node Captions why ?
« Reply #3 on: June 08, 2021, 07:35:32 am »
Sorry my Bad ... was using VirtualtreeView and all of my Nodes are Multiline so if it would be to long it should create a new Line.

But this Caption is like 2-3 Chars too long and then it gets truncated.

Edit: Here is how i add Nodes

Code: Pascal  [Select][+][-]
  1.            dbExecute(RsSprachen, 'SELECT * FROM Sprachen WHERE ID = ' + Query.FieldByName('BezID').AsString);
  2.            Node := VST.AddChild(Root);
  3.            Data := VST.GetNodeData(Node);
  4.            Data^.Bezeichnung := RsSprachen.FieldByName(FeldD).AsString;
  5.            Data^.Tag:= Query.FieldByName('ID').AsString;
  6.            VST.MultiLine[Node] := True;
  7.  

The Node height for multiline gets calculated corretly.
« Last Edit: June 08, 2021, 07:39:25 am by Weitentaaal »

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: TreeView truncating my Node Captions why ?
« Reply #4 on: June 08, 2021, 10:04:16 am »
The truncation ellipsis ('...') somewhere in the middle of your screenshot indicate that you activated the GridExtensions option. If you turn this off, does the issue disappear?

Weitentaaal

  • Hero Member
  • *****
  • Posts: 516
  • Weitental is a very beautiful garbage depot.
Re: TreeView truncating my Node Captions why ?
« Reply #5 on: June 08, 2021, 02:47:39 pm »
No the issue still here. But what exactly does this ? The Description is "Use some special enhancements to simulate and support grid behavior." But what behavior does get supported ?


Edit: Found out that this is happening to every Node if the text is exceeding the column width, but only for about 3-5 chars, If there are more Chars then a New Line will get generated.
« Last Edit: June 08, 2021, 03:15:04 pm by Weitentaaal »

Weitentaaal

  • Hero Member
  • *****
  • Posts: 516
  • Weitental is a very beautiful garbage depot.
Re: TreeView truncating my Node Captions why ?
« Reply #6 on: June 09, 2021, 04:12:37 pm »
Does no one have any idea what I could be doing wrong ?

wp

  • Hero Member
  • *****
  • Posts: 11916
Re: TreeView truncating my Node Captions why ?
« Reply #7 on: June 09, 2021, 04:47:35 pm »
Seeing https://github.com/JAM-Software/Virtual-TreeView/issues/174 I think that this is a bug of VTV. It probably is fixed in the official version, but the Lazarus version is way behind...

If you prepare a compilable demo for me which shows the issue I can try to apply the fixes mentioned in that report.

lucamar

  • Hero Member
  • *****
  • Posts: 4219
Re: TreeView truncating my Node Captions why ?
« Reply #8 on: June 09, 2021, 05:30:21 pm »
Does no one have any idea what I could be doing wrong ?

I might be wrong but I think the problem is (was?) that the code doesn't find a good place to cut the line (e.g. a space) before reaching too soon the end of the string, so it cuts close to the end and adds the "..." instead of going back and breaking it up at a previous "delimiter".

I kind of remember WrapText() (or a similar function) had the same problem when the string exceeded the max length by a few chars and the last word was very long, like the Spanish "solamente" or one of those tongue-twisters Northern folks are so fond of ;)
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Weitentaaal

  • Hero Member
  • *****
  • Posts: 516
  • Weitental is a very beautiful garbage depot.
Re: TreeView truncating my Node Captions why ?
« Reply #9 on: June 10, 2021, 10:16:41 am »
Thanks Guys... so if its a bug i have to use my creativity :D

Seeing https://github.com/JAM-Software/Virtual-TreeView/issues/174 I think that this is a bug of VTV. It probably is fixed in the official version, but the Lazarus version is way behind...

If you prepare a compilable demo for me which shows the issue I can try to apply the fixes mentioned in that report.

My Project is way to big :/ i would be faster if i would rewrite a demo programm for yo. I Did try to write 1 but i just couldn't simulate the problem anymore. i don't know if its just a mistake i did somewhere.
Does no one have any idea what I could be doing wrong ?

I might be wrong but I think the problem is (was?) that the code doesn't find a good place to cut the line (e.g. a space) before reaching too soon the end of the string, so it cuts close to the end and adds the "..." instead of going back and breaking it up at a previous "delimiter".

I kind of remember WrapText() (or a similar function) had the same problem when the string exceeded the max length by a few chars and the last word was very long, like the Spanish "solamente" or one of those tongue-twisters Northern folks are so fond of ;)

Did u Fix this somehow ?

Zvoni

  • Hero Member
  • *****
  • Posts: 2327
Re: TreeView truncating my Node Captions why ?
« Reply #10 on: June 10, 2021, 11:57:25 am »
1) Is it a VirtualTreeView or VirtualStringTree? (Your "VST" implies VirtualStringTree!) --> https://forum.lazarus.freepascal.org/index.php/topic,53957.0.html
2) What i find odd, is that you set the captions of the Node(s), and then afterwards you set the Node to Multiline
Have you tried to set MultiLine for the Node as the first thing after creating it, and then filling the Captions? And don't forget to invalidate the Node and/or to refresh the Tree again!
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

dseligo

  • Hero Member
  • *****
  • Posts: 1221
Re: TreeView truncating my Node Captions why ?
« Reply #11 on: June 10, 2021, 05:34:24 pm »
I Did try to write 1 but i just couldn't simulate the problem anymore. i don't know if its just a mistake i did somewhere.

If you can't recreate problem in test case then there is a good chance that you made mistake in your program or you set something in your program that triggers the problem.
If other advices won't help you, you'll have to analyze part by part and see when problem start/stop showing. Maybe you can start by creating new form with TreeView in your program and see if there is a problem with that one.

dseligo

  • Hero Member
  • *****
  • Posts: 1221
Re: TreeView truncating my Node Captions why ?
« Reply #12 on: June 10, 2021, 05:36:57 pm »
Maybe TreeView uses some fixed font to calculate width and you changed font?
That would explain difference of length when text goes to new line.

 

TinyPortal © 2005-2018