Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    BackgroundClickHandler called when Event is clicked

    I'm trying to use my custom form to edit a CalendarEvent. So I added a BackgroundClickHandler as folows

    Code:
    Calendar calendar = new Calendar();
    calendar.addBackgroundClickHandler(onBackgroundClickCalendar);
    and the handler

    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);
    		}
    	};
    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

    Code:
    private native final void clearCalendarSelection(Calendar calendar)/*-{
    	obj = calendar.@com.smartgwt.client.widgets.BaseWidget::getJsObj()();
    	obj.clearTimeSelection();
    }-*/;
    You should call this method right after cancelling the event.

    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);
    	}
Working...
X