Skip to content

Commit

Permalink
Merge pull request GwtMaterialDesign#342 from vegegoku/master
Browse files Browse the repository at this point in the history
  • Loading branch information
BenDol committed May 28, 2016
2 parents 7eb2738 + 907dfc3 commit 021fa46
Showing 1 changed file with 29 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package gwt.material.design.client.ui;

import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;

/*
* #%L
* GwtMaterial
Expand Down Expand Up @@ -530,8 +533,32 @@ public void setAccessKey(char key) {
}

@Override
public void setFocus(boolean focused) {
valueBoxBase.setFocus(focused);
public void setFocus(final boolean focused) {
Scheduler.get().scheduleDeferred(new ScheduledCommand() {

@Override
public void execute() {
valueBoxBase.setFocus(focused);
if (focused) {
label.addStyleName("active");
} else {
updateLabelActiveStyle();
}
}
});
}

/**
* Updates the style of the field label according to the field value if the
* field value is empty - null or "" - removes the label 'active' style else
* will add the 'active' style to the field label.
*/
private void updateLabelActiveStyle() {
if (this.valueBoxBase.getText() != null && !this.valueBoxBase.getText().isEmpty()) {
label.addStyleName("active");
} else {
label.removeStyleName("active");
}
}

@Override
Expand Down

0 comments on commit 021fa46

Please sign in to comment.