Using SWT on Mac. I create a Unified ToolBar. On this toolbar there is a Scale widget, and a Label widget. The label displays the current value of the scale, updated by a SelectionListener on the Scale

On program launch, the thumb of the scale widget will not move. The label shows the value is changing exactly as expected, the Scale widget is correctly tracking cursor movement, and reporting the changed value. The thumb does not move.
Closing the Unified toolbar and re-opening it (using the small button top right) makes the thumb fully operational. The thumb tracks the cursor.
Simple, compilable, runnable test code replicating problem is here:
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.*;
public class scaleTest
{
private static Shell shell;
private static Display display;
private ToolBar UnifiedToolBar;
private Scale scale;
private scaleTest()
{
UnifiedToolBar = shell.getToolBar();
ToolItem containScale = new ToolItem( UnifiedToolBar, SWT.SEPARATOR );
containScale.setWidth( 200 );
scale = new Scale( UnifiedToolBar, SWT.HORIZONTAL );
scale.setMaximum( 72 );
scale.setSelection( 2 );
scale.setMinimum( 6 );
scale.setIncrement( 4 );
scale.setPageIncrement( 4 );
scale.setSize( 180, 24 );
containScale.setControl( scale );
ToolItem containLabel = new ToolItem( UnifiedToolBar, SWT.SEPARATOR );
containLabel.setWidth( 20 );
final Label label = new Label( UnifiedToolBar, SWT.NONE );
label.setText( "32" );
containLabel.setControl( label );
scale.addSelectionListener( new SelectionAdapter()
{
@Override
public void widgetSelected( SelectionEvent selectionEvent )
{
label.setText( String.valueOf( scale.getSelection() ) );
}
} ); // end addSelectionListener
} // end of constructor
public static void main( String[] args )
{
display = Display.getDefault();
shell = new Shell( display );
shell.setText( "scaleTest App" );
shell.setSize( 400, 200 );
shell.setLocation( (display.getClientArea().width / 2) - 200
,(display.getClientArea().height / 2) - 100 );
shell.setLayout( new FormLayout() );
scaleTest testExample = new scaleTest();
shell.open();
while( !shell.isDisposed() )
{
if( !display.readAndDispatch() )
display.sleep();
}
display.dispose();
}
} // end scaleTest class
I have tried layout(), layout(true, true), redraw(), paint(), pack(), on the shell, the toolbar, and the Scale widget in as many combinations as seemed reasonable. A normal human being would consider it an unreasonably large number of combinations.
Question 1: How to get the thumb working normally on start-up?
Follow up question, of much lesser importance:
Question 2: The Scale widget appears to ignore both pageIncrement and increment settings. Why?
Any assistance would be very much appreciated.
Update: Late night playing around. Moving the Scale widget to the shell – and no other change to the test code included above, widget works as desired – thumb works right off the bat. It would see the Scale and the unified toolbar don’t like each other too much on first sight.
Question 2:
You can achieve the “snapping” to the step values by adding a
ListenertoSWT.Selection. In the code below it will snap to all multiples of5:I can’t really help you with Question 1 though…