I'm trying to use my custom form to edit a CalendarEvent. So I added a BackgroundClickHandler as folows
and the handler
but AFTER clicking an empty space once and trying to edit an event -clicking on it- it fires the BackgroundClickHandler as if an empty space was clicked.
I've found the problem is the time range remains selected and causes trouble.
To solve the issue I've added a clearCalendarSelection method as follows
You should call this method right after cancelling the event.
Code:
Calendar calendar = new Calendar(); calendar.addBackgroundClickHandler(onBackgroundClickCalendar);
Code:
BackgroundClickHandler onBackgroundClickCalendar = new BackgroundClickHandler() {
@Override
public void onBackgroundClick(BackgroundClickEvent event) {
event.cancel();
CalendarEvent evnt = new CalendarEvent();
evnt.setStartDate(event.getStartDate());
evnt.setEndDate(event.getEndDate());
editEvent(evnt);
}
};
I've found the problem is the time range remains selected and causes trouble.
To solve the issue I've added a clearCalendarSelection method as follows
Code:
private native final void clearCalendarSelection(Calendar calendar)/*-{
obj = calendar.@com.smartgwt.client.widgets.BaseWidget::getJsObj()();
obj.clearTimeSelection();
}-*/;
Code:
@Override
public void onBackgroundClick(BackgroundClickEvent event) {
event.cancel();
[b]clearCalendarSelection(calendar);[/b]
CalendarEvent evnt = new CalendarEvent();
evnt.setStartDate(event.getStartDate());
evnt.setEndDate(event.getEndDate());
editEvent(evnt);
}