как различить щелчок и двойной щелчок по календарю встреч? - PullRequest
0 голосов
/ 06 июня 2019

Я использую календарь планирования. У меня есть функция щелчка на встрече с календарем, и я настроил встречу с помощью двойного щелчка. если я дважды щелкаю по назначению, срабатывает функция как щелчка, так и двойного щелчка. Как это исправить?

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

1 Ответ

0 голосов
/ 06 июня 2019

Используйте тайм-аут для отмены простого клика в случае получения второго клика за короткий промежуток времени

// 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;
});
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...