I think this can still be implemented for cells without any special handling.
It is rather unexpected that a cell does not give the correct pref width, so we need to think about how to improve the current situation.
In my opinion, it should not be the concern of the Cell to give the actual width of the column it belongs to, but the pref width, as we would expect.
We need to check where this is called.
-- Marius
Gesendet: Donnerstag, 07. März 2024 um 16:07 Uhr
Von: "Daniel Peintner" <daniel.peint...@gmail.com>
An: "Andy Goryachev" <andy.goryac...@oracle.com>
Cc: "openjfx-dev@openjdk.org" <openjfx-dev@openjdk.org>
Betreff: Re: [External] : Re: Q: Labeled.textTruncated Property (RFE)
Von: "Daniel Peintner" <daniel.peint...@gmail.com>
An: "Andy Goryachev" <andy.goryac...@oracle.com>
Cc: "openjfx-dev@openjdk.org" <openjfx-dev@openjdk.org>
Betreff: Re: [External] : Re: Q: Labeled.textTruncated Property (RFE)
Andy, all,
Some comments below:
Some comments below:
- Even if it is possible to do the same with public means I think it is useful. Anyhow we need to promote the solutions better (e.g., on StackOverflow)
- I tried to achieve what you did in JavaFX core for my use-case, TableView cells.
- In my real application I tried and failed since the boolean condition in https://github.com/openjdk/jfx/blob/8a5cb17ed6525b0a218595865ead3e399e3b29dd/modules/javafx.controls/src/main/java/javafx/scene/control/Labeled.java#L838-L841 always reports false
- Hence I tried to create a short self-contained TableView example to explore it further, see Gist https://gist.github.com/danielpeintner/9b561eb57261e8c5bc608f1346df74cf
It still fails :-( - The Email field in the table ideally should report "true" once the text entered exceeds the visible view. Somehow it fails... getWidth() and prefWidth(-1) always return the same double value. Please try the Gist above to confirm.
e.g., edit cell and extend the email text to longer than column width --> results in System.out "Table-Email-Cell !isWrapText: 182.0 < 182.0 --> false" - Hence I also added a *normal* MyLabel example which does work as intended
Maybe I miss something obvious but TableCells seem to be special Labeled instances and behave differently.
Thanks,
-- Daniel
On Wed, Mar 6, 2024 at 6:10 PM Andy Goryachev <andy.goryac...@oracle.com> wrote:
Dear Daniel:
Thank you for confirming the need for this enhancement. Your case is covered by this ticket (I included a wrong ticket in my previous message by mistake, sorry):
JDK-8327483 TreeView: Allow for tooltip when cell text is truncated
My only concern is that this functionality theoretically can be achieved by the application code just as easy, since the solution does not use any internal APIs, as can be seen here: https://github.com/openjdk/jfx/pull/1389
-andy