Hi pieceovcake,
yes, we're using sth. like you've mentioned a lot in our application. It
looks sth. like this:
...
private TextArea _ta;
...
_ta.setText("placeholder");
_ta.setStyleName("textarea-placeholder");
_ta.addFocusHandler(new FocusHandler() {
@Override
public void onFocus(final FocusEvent event) {
if (_isBlank) {
_ta.setText("");
}
_ta.setStyleName("textarea-text");
_submitText.setVisible(true); // a submit button
}
});
_ta.addBlurHandler(new BlurHandler() {
@Override
public void onBlur(final BlurEvent event) {
if (ClientStringUtil.isBlank(_ta.getText().trim())) {
_isBlank = true;
} else {
_isBlank = false;
}
blurTextArea();
}
});
...
private void blurTextArea() {
if (_isBlank) {
_submitText.setVisible(false); // hide the submit button
_ta.setStyleName("textarea-placeholder");
_commentText.setText("placeholder");
}
}
We're using the _isBlank field to indicate that the user has typed sth. into
the text area and we don't replace this with the placeholder text if he
exists the area. But that's a matter of taste and requirements.
HTH
Max
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.