Re: Default value in empty TextBox

2014-08-07 Thread Ismael Hasan
Kudos for Moutellou, I find his solution very clean. 

HTML already provides the capability to fulfil the initial requirement, so 
I think it is best taking advantage of that instead of dealing with more 
GWT artifacts and re-building a functionality that already exists. 




El miércoles, 27 de noviembre de 2013 14:24:13 UTC+1, Moutellou escribió:

 You can try the attribute placeholder 
 http://www.w3schools.com/tags/att_input_placeholder.asp.
 getElement().setPropertyString(placeholder, default value)

 On Thursday, February 7, 2008 9:10:17 AM UTC-5, Brock Parker wrote:

 Hello, 

 Is there anything built into GWT to display a value in a TextBox if 
 the field is emtpy?  This value would disappear once the user clicked 
 in the field and started typing.  I have seen this functionality on 
 several Google web pages (i.e. the Contacts page in GMail) but I can't 
 find anything in the documentation or samples about it. 

 Thanks, 

 Brock



-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.


Re: Default value in empty TextBox

2013-11-27 Thread Zied Hamdi
Hi all,

There is ready version (among other widgets) in the buttom of this page 
http://1vu-widgets.appspot.com/IntoGwt.html

The project homepage is 
https://code.google.com/p/advanced-suggest-select-box/

Best regards


On Wednesday, March 19, 2008 7:25:53 AM UTC+1, Christopher wrote:

 Thanks for the code. Here's my extension of it: 

 public class DefaultTextBox extends TextBox implements FocusListener { 
 String defaultText; 
 boolean defaultTextMode = false; 

 public DefaultTextBox(String defaultText) { 
 setDefaultText(defaultText); 
 setDefaultTextMode(); 
 addFocusListener(this); 
 } 

 public String getDefaultText() { 
 return defaultText; 
 } 

 public String getText() { 
 if (!defaultTextMode) { 
 return super.getText(); 
 } else { 
 return ; 
 } 
 } 

 public void onFocus(Widget sender) { 
 if (defaultTextMode) { 
 setNormalTextMode(); 
 } 
 } 

 public void onLostFocus(Widget sender) { 
 if (getText().length() == 0) { 
 setDefaultTextMode(); 
 } 
 } 

 public void setDefaultText(String defaultText) { 
 this.defaultText = defaultText; 
 if (defaultTextMode) { 
 setDefaultTextMode();// Refresh 
 } 
 } 

 void setDefaultTextMode() { 
 assert super.getText().length() == 0; 
 super.setText(defaultText); 
 addStyleDependentName(default); 
 defaultTextMode = true; 
 } 

 void setNormalTextMode() { 
 assert super.getText().length() != 0; 
 super.setText(); 
 removeStyleDependentName(default); 
 defaultTextMode = false; 
 } 

 public void setText(String text) { 
 super.setText(text); 
 if (text.length() == 0) { 
 setDefaultTextMode(); 
 } else { 
 setNormalTextMode(); 
 } 
 } 
 } 

 Cheers, 
 -C

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Default value in empty TextBox

2013-11-27 Thread Moutellou
You can try the attribute 
placeholderhttp://www.w3schools.com/tags/att_input_placeholder.asp
.
getElement().setPropertyString(placeholder, default value)

On Thursday, February 7, 2008 9:10:17 AM UTC-5, Brock Parker wrote:

 Hello, 

 Is there anything built into GWT to display a value in a TextBox if 
 the field is emtpy?  This value would disappear once the user clicked 
 in the field and started typing.  I have seen this functionality on 
 several Google web pages (i.e. the Contacts page in GMail) but I can't 
 find anything in the documentation or samples about it. 

 Thanks, 

 Brock

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/groups/opt_out.