It appears that a selected item in a GWT Material DropDown does not "stick" like a traditional DropDown.
First question, is that intended with new Material Designs? Am I doing something wrong? Is there something wrong with the library I am using?
Secondly, either way, I want the selected value to take the place of the default text. Is there a better way to do it than this?
UIBinder:
<m:MaterialContainer ui:field="materialContainer" paddingLeft="280">
<m:MaterialButton ui:field="areaDropDownButton" text="Area" iconType="ARROW_DROP_DOWN" iconPosition="RIGHT" textColor="white" backgroundColor="green" activates="areaDropDown"/>
<m:MaterialDropDown ui:field="areaDropDown" activator="areaDropDown" constrainWidth="true" />
</m:MaterialContainer>
Java:
this.areaDropDown.addSelectionHandler(new SelectionHandler()
{
@Override
public void onSelection(SelectionEvent event) {
areaDropDownButton.setText(event.getSelectedItem().toString());
}
});
GWT Material Demo: http://gwtmaterialdesign.github.io/gwt-material-demo/#!dropdown
You could also use an UiHandler:
@UiHandler("areaDropDown")
void onDropdown(SelectionEvent event){
areaDropDownButton.setText(event.getSelectedItem()).getText());
}
should work