How to disable DatePicker in GWT?

As you know, com.google.gwt.user.datepicker.client. DatePicker do not have a setEnabled (boolean) method. I have a DatePicker with a ValueChangeHandler, and all I need is to disable the datepicker (the code in onValueChange should not work).

Of course I can do:

boolean disable;

datePicker.addValueChangeHandler (new ValueChangeHandler () {

@Override public void onValueChange(ValueChangeEvent<Date> event) { if(!disable) { // my code here } } }); 

but I won’t do it. I want to write something like this:

datePicker.setEnabled (false);

Any ideas?

GWT 2.3.0

+4
source share
1 answer

I did not use GWT after a while, so this is more of a pointer than an answer, but I wanted to include some links, so I used the response field;).

DatePicker is Composite , so I don’t think you can turn it on / off directly. But you can add a preview handler to disable events, or drop a panel above it (and, for example, gray). See this answer for information on this: Disable user interaction in a GWT container?

As a general note, everything that extends from FocusWidget is on / off, but composites are collections of other widgets, so they work differently.

+3
source

All Articles