Spinner button size

Is there any way to make the buttons on the spinner wider?
Resizing the spinner only adjusts the button height, but not the width.
I will be using Ignition in a touch panel and would like wider buttons so they are easier to press for users.

Not currently, but it’s on our list of things to do some time in 7.7

Was this ever addressed in 7.7 or 7.8? Is it possible to resize the spinner buttons?

1 Like

Has this been addressed yet? The spinner isn’t very useful on a touch panel without being able to increase the button size.

Thanks!

I can’t see any way to make them wider in 7.9.2, so probably not yet.

If the button size is really important, there is a dirty hack:

Add a custom method ‘setWidth’ with a parameter ‘w’ to your spinner component:

def setWidth(self, w):
	"""
	Arguments:
		self: A reference to the component instance this method is invoked on. This argument
		  is automatic and should not be specified when invoking this method.
		width: The button width
	# First component of the JSpinner should be the 'up' button
	btn1 = self.getComponent(0)

	# the field 'c' is returned by getPreferredSize() of the button
	c = btn1.getClass()
	sizeField = c.getDeclaredField("c")
	sizeField.setAccessible(1);
	
	# set the new button size. only the width is used, the height is determined by the text editor
	from java.awt import Dimension
	newSize = Dimension(w,w)
	sizeField.set(btn1, newSize)
	self.doLayout()
	self.getComponent(2).doLayout()

Call the new method in the spinner’s propertyChange script:

if event.propertyName in ('editor', 'componentRunning' ):
	# editor: designer preview mode
	# componentRunning: client
	event.source.setWidth(30)

In the designer, the width will only be updated when switching to preview node.

4 Likes

In case someone wants to do that in Ignition 8.
Here is an updated version of this method to work with Java 11

def setWidth(self, w):
	"""
	Arguments:
		self: A reference to the component instance this method is invoked on. This argument
		  is automatic and should not be specified when invoking this method.
		width: The button width
    """
	# First component of the JSpinner should be the 'up' button
	btn1 = self.getComponent(0)

	# set the new button size. only the width is used, the height is determined by the text editor
	from java.awt import Dimension
	newSize = Dimension(w,w)

	btn1.setPreferredSize(newSize)
	self.doLayout()
	self.getComponent(2).doLayout()
2 Likes

Nice, I think I can live with that vertical line in there
image