I want to create a context-menu under a right click for every Event in SmartGWT Calendar or simply handle right-click on event to display a pop-up window.
calendar.addEventClickHandler(new EventClickHandler() {
@Override
public void onEventClick(TimetableEventClick event) {
// TODO Auto-generated method stub
}
});
Code above don't let me to differ actions depending on left/right mouse was clicked. There is a handler I can add to calendar instance:
calendar.addRightMouseDownHandler(new RightMouseDownHandler() {
@Override
public void onRightMouseDown(RightMouseDownEvent event) {
// TODO Auto-generated method stub
}
});
...but how can I get info which event was clicked exactly? No event.getId() available, neither anything similar. I suppose getX(), getY() and playing with position is not a solution?
BTW: Is handling right-clicks in GWT still a bad habit? Should I leave its functionality for a browser?
You can pass the calendar as a parameter to the constructor of the handler. When the click is triggered, you get the selected date from the calendar
I guess this is what you want:
I don't think hadling right-click in GWT is a bad habit. If it is so, these methods would have not been defined in the API to be overridden.
You use a general ClickEvent handler and use the functions of the calendar object getActiveTime() and/or getActiveDay() to fetch the position of the cell the pointer was hovering over. The code above is using UI Binder but will work similarly with normal JAVA GWT code.
The right click functionality for calendar does not exist natively.
This article sums up GWT's deficiency in this area pretty well and a way to override it.
http://whatwouldnickdo.com/wordpress/370/gwt-right-click-context-menu/