Layout on numeric text field versus numeric label

image

We are using the "numeric text field" object for operators to enter setpoints (white text) and the "numeric label" object to display readbacks (blue text). Everything is set to Relative Layout with maintain aspect ratio set to Leading and Scale Font is on. They are both within Templates.

The issue is that when we open faceplates etc. and the main window shrinks, these two objects seem to scale differently. the Numeric text field starts cutting off the numbers completely instead of scaling properly like the label does. We're still in testing mode but I know the operators are not going to be happy with this at all.

I tested it with a "fresh" and non-templated Numeric text field object and it is working properly - it doesn't get cut-off. But the whole point of using this software was to make things easy by using Templates. Something else is weird, if I copy only the numeric text field object from within the existing template and paste it on the window externally (not in the template) it still does the bad cutting off scaling behaviour even though it's not inside the template anymore. This seems like a glitchy bug to me?

It doesn't seem like we have a choice to use a different object because the numeric text field is the only one that has the "out of bounds" type settings that we need to use.

Anyway this can get fixed or am I SOL?

I was able to recreate this problem, and there were a couple of things I did that improved the result.

• When testing this template, making the numeric text fields a few pixels taller to give the font more room seemed to help.

• I get better results from my templates if I do not resize them in the window editor, so if you are squishing or stretching the template to get it to fit into the window, you could be creating some scaling issues. Try designing the templates so they fit perfectly where they belong in the window editor

If you still can't get the font to play nice in your environment after implementing the above suggestions, you can turn the numeric text field's font scaling off and add a listener to manually scale the font.
Example:
Right Click on the component --> Select Layout --> Uncheck Scale Font
image

Then, add this script to the numeric text field's propertyChange event handler:

# Only runs once in the client environment when the component is first initialized.
if event.propertyName == 'componentRunning':
	from java.awt import Font
	from java.awt.event import ComponentAdapter
	class FontAdjuster(ComponentAdapter):
		
		# Method to handle the component resize event.
		def componentResized(self, event):
		
			# Method to adjust the font sizes of labels in the calendar.
			def adjustFontSize():
				
				# Calculate and set font size based on the component's height.
				fontSize = int(event.source.height * 0.5)
				event.source.font = Font('Dialog', Font.PLAIN, fontSize)
				
			# When the calendar component is resized, adjust the font size.
			system.util.invokeLater(adjustFontSize)
	event.source.addComponentListener(FontAdjuster())

Here is the result:
Note the difference between the top numeric text field that has the listener, and the bottom numeric text field that does not:
image

The script simply adds a listener that will set the font to half the height of the numeric text field any time the component is resized in some way.

Thanks. I was already doing #2, but I've tried #1 now...I made the text field 25 high even though the template is only 20 high...that seems to have helped a fair bit actually.
Thanks!