-1

i am using planning calendar.i have a click function on the calendar appointment and i have customized the calendar appointment with Double click. if i double click on the appointment both click and double click function is getting triggered.how to fix this ?

// this is the custom Calendar Appointment code.

sap.ui.define([
  "sap/ui/unified/CalendarAppointment"
],
function (
  CA
) {
  "use strict";
  var CalendarAppointment = CA.extend("com..........util.CalendarAppointment", {
    metadata: {
      events: {
        "rightpress": {},
        "dblclick": {}
      }
    }
  });
  CalendarAppointment.prototype.oncontextmenu = function (ovt) {
    this.fireRightpress();
  };
  CalendarAppointment.prototype.ondblclick = function (ovt) {
    this.fireDblclick();
  };
  return CalendarAppointment;
});
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
  • 1
    what is triggered on the double click ? You should also post your code here – axel axel Jun 06 '19 at 07:23
  • 1
    There is similar question https://stackoverflow.com/questions/5497073/how-to-differentiate-single-click-event-and-double-click-event – Victor Jun 06 '19 at 07:35

1 Answers1

0

Use a timeout to cancel simple click in case a second click is received in a short interval

// this is the custom Calendar Appointment code.

sap.ui.define([
  "sap/ui/unified/CalendarAppointment"
],
function (
  CA
) {
  "use strict";
  var CalendarAppointment = CA.extend("com..........util.CalendarAppointment", {
    metadata: {
      events: {
        "rightpress": {},
        "dblclick": {}
      }
    }
  });
  CalendarAppointment.prototype.oncontextmenu = function (ovt) {
    clearTimeout(this._singleClickTimeout)
    var DURATION = 250;
    this._singleClickTimeout = setTimeout(() => {
      this.fireRightpress();
    }, DURATION)
  };
  CalendarAppointment.prototype.ondblclick = function (ovt) {
    clearTimeout(this._singleClickTimeout)
    this.fireDblclick();
  };
  return CalendarAppointment;
});
Ji aSH
  • 3,206
  • 1
  • 10
  • 18