The need for a FixedText control
Randahl Fink Isaksen
randahl at rockit.dk
Fri Jun 15 10:58:31 PDT 2012
I think JavaFX is missing a text control for presenting uneditable,
styled text - a FixedText control. As I am about to file a feature
request, I thought it would be relevant to discuss it here first.
In the following UI the left column shows three labels implemented using
Label, and the the right column has a field showing the Customer ID, a
CheckBox for editing the VIP status of the customer, and finally a
TextField for adding some kind of note about the VIP status:
Customer ID: 12345678 (non-editable text)
VIP: [x] (editable
VIP note: |_________| (editable TextField
In this UI, the user is always able to edit the VIP CheckBox, and if it
is checked, the previously uneditable VIP note TextField becomes
editable. The customer ID is never editable. So what component do we
choose when implementing the uneditable customer ID field? Our options are:
1. Implementing the customer ID field as a label.
2. Implementing the customer ID as a TextField which is marked uneditable.
3. Implementing the customer ID as a raw Text instance.
None of these options are very pleasing:
- 1. Using a label is semantically incorrect, since it does not label
anything (the labelFor property would have no meaning). Also, it would
at least require a special style class to distinguish it from real
labels, and it would not be efficient to have to set this style class
everywhere we have a non-editable text field.
- 2. Using a TextField for which editable has been set to false is not
that good an idea either - by default, TextFields are rendered as a box,
which indicates that the user can input something here, at least at
least in some situations (like the VIP status field above). Again, we
would require special styling for it to look different from other real
TextFields, and we would have to set a specific style class everywhere
we had a non-editable text field.
-3. Using a raw Text instance is a bad idea too, since it is not a real
JavaFX Control, which means it does not automatically have a style class
of "text", it is not skinnable, cannot be copied using mouse gestures,
is not draggable, etc.
So my thoughts are, that JavaFX could benefit from a FixedText control.
This would work much like a TextField, only it would mean "a forever
uneditable text control". It would by default have a style class of
"fixed-text", the user would be able to mark and copy its contents, drag
it, etc. - just like the contents of a TextField.
More information about the openjfx-dev