Changing label position when the field is not empty [message #1861434] |
Thu, 12 October 2023 12:26 |
J D Messages: 102 Registered: February 2021 |
Senior Member |
|
|
Hi there everyone,
I'm looking for a way to change label position automatically when the field (string, integer, long) is not empty.
In certain forms, I have LABEL_POSITION_ON_FIELD as the configured label position but once the user starts typing in the field, I want the label position to be on top i.e LABEL_POSITION_TOP. And if the value in the field is deleted, I want the label on the field again i.e LABEL_POSITION_ON_FIELD.
It is something I used to do with JavaFX and I would like to reproduce it with Eclipse Scout if possible.
Has anyone done this already?
Thanks a million for your assistance.
Cheers,
JD
[Updated on: Thu, 12 October 2023 12:28] Report message to a moderator
|
|
|
Re: Changing label position when the field is not empty [message #1861450 is a reply to message #1861434] |
Fri, 13 October 2023 07:40 |
Michel R Messages: 46 Registered: April 2015 |
Member |
|
|
Hello JD
I just tried something, it seems that it can work.
In the field class you can add this:
@Override
protected String execValidateValue(String rawValue) {
if (rawValue==null||"".equals(rawValue)) {
this.setLabelPosition(LABEL_POSITION_ON_FIELD);
}
else {
this.setLabelPosition(LABEL_POSITION_TOP);
}
return super.execValidateValue(rawValue);
};
When the user exits the field, or clears it, the execValidateValue method is called.
Remark: it doesn't work when the user starts typing, only when he is done. But I am not sure that as a user I would like the field to jump down as soon as I type in it.
Regards
Michael
[Updated on: Fri, 13 October 2023 07:45] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.04177 seconds