Label Text Selection

Dirk Lemmermann dlemmermann at gmail.com
Mon Aug 19 07:29:18 UTC 2024


That looks like a much better approach. We implemented the initial version of the selectable text control for JavaFX 8, so the whole hit point API wasn’t even there back then (or at least not public). I think I will move the control to use your approach … which is probably what the TextArea is doing as well?

Dirk

> On 16 Aug 2024, at 17:40, quizynox <quizynox at gmail.com> wrote:
> 
> Hello,
> 
> Both TextFlow and Text support the HitInfo API, which makes getting selected characters very easy. Then you just need to wrap the selected characters in Path. The way it is implemented in GemsFX with overlay pane is quite complicated. Here is a rough sketch of the selectable TextFlow I plan to release in AtlantaFX. I think implementing a selectable Label by wrapping a text node in Region isn't much harder. But I wouldn't mind if it was the Label out-of-the-box feature, although I think it would require implementing some sort of selection model, so it's unlikely to happen.
> 
> source code:
> https://pastebin.com/9QKWYfx1
> 
> On 16/08/2024 14.12, Dirk Lemmermann wrote:
>> Hi everyone,
>> 
>> I recently added a custom text control (called “TextView") to the GemsFX project. It supports a somewhat limited text selection. Selection is only possible on a per-word basis. I received a bit of feedback on this control and I was wondering whether it would be worth thinking about adding a general text selection capability to labels. Is this something worth looking into? Is it even feasible?
>> 
>> I guess one of the reasons why this topic keeps popping up is the fact that users are so used to selecting any text in web pages, but they can’t do it in desktop apps.
>> 
>> Dirk
>> 



More information about the openjfx-dev mailing list