Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Changing label position when the field is not empty(Switching between LABEL_POSITION_ON_FIELD and LABEL_POSITION_TOP)
Changing label position when the field is not empty [message #1861434] Thu, 12 October 2023 12:26 Go to next message
J D is currently offline J DFriend
Messages: 100
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 Go to previous messageGo to next message
Michel R is currently offline Michel RFriend
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

Re: Changing label position when the field is not empty [message #1861574 is a reply to message #1861450] Thu, 19 October 2023 12:49 Go to previous message
J D is currently offline J DFriend
Messages: 100
Registered: February 2021
Senior Member
Hi there Michael,

Thanks a lot. It works as expected.

JD
Previous Topic:HelloScout not working with Eclipse 2023-09
Next Topic:Access to Diagnostic servlet
Goto Forum:
  


Current Time: Wed May 08 08:56:25 GMT 2024

Powered by FUDForum. Page generated in 0.03906 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top