简体   繁体   中英

Clicking the radio button is not updating the layout when using databinding in RCPTT

As you can see from the image, the Right button is checked but the label says LEFT AREA which should be RIGHT AREA

选中了右侧按钮,但仍显示左侧区域标签

Script used in RCPTT

get-button Right | click

Here's the sample snippet of the ui. When a button is checked, a label will show up saying which button is clicked.

DataBindingContext dataBindingContext = new DataBindingContext();

IObservableValue<Boolean> left = new WritableValue<>( true, Boolean.class );
IObservableValue<Boolean> right = new WritableValue<>( false, Boolean.class );

Composite sampleComposite = new Composite( parent, SWT.NONE );
sampleComposite.setLayout( GridLayoutFactory.fillDefaults().numColumns( 2 ).create() );

Button leftBtn = new Button( sampleComposite, SWT.RADIO );
leftBtn.setText( "Left" );
dataBindingContext.bindValue( WidgetProperties.buttonSelection().observe( leftBtn ), left );

Button rightBtn = new Button( sampleComposite, SWT.RADIO );
rightBtn.setText( "Right" );
dataBindingContext.bindValue( WidgetProperties.buttonSelection().observe( rightBtn ), right );

StackLayout stackLayout = new StackLayout();
Composite stackComposite = new Composite( sampleComposite, SWT.NONE );
    stackComposite.setLayout( stackLayout );

Label leftLbl = new Label( stackComposite, SWT.NONE );
leftLbl.setText( "LEFT AREA" );

Label rightLbl = new Label( stackComposite, SWT.NONE );
rightLbl.setText( "RIGHT AREA" );

ISideEffect.create( () -> {
    stackLayout.topControl = left.getValue() ? leftLbl : rightLbl;
    stackComposite.layout();
} );

I was able to fix this issue by creating my own custom ecl command that sends selection event and deselect every radio button in the same composite and just select the target radio button. looks like aut is not deselecting the surrounding radio button when you use click command

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM