I am running into an issue with the dp.multirange.get() returns nothing when it is being called from context menu initiated by touch, which would otherwise work fine when called from a context menu called by the mouse. Is there a different behavior with dp.multirange.get() when the range is selected by touch instead of mouse?
Comment posted by Dan Letecky [DayPilot] 2 years ago.
Hi Vincent,
Sorry for the delay.
There should be no difference between time range selections created using mouse and touch. I do not see this problem.
Would you be able to post the config that reproduces the issue?
Comment posted by Vincent 2 years ago.
dp.timeRangeSelectedHandling = "Hold";
dp.timeRangeRightClickHandling = "ContextMenu";
dp.onTimeRangeSelected = function (args) {
timerangeContextMenu.show({ calendar: dp });
};
var timerangeContextMenu = new DayPilot.Menu({
items: [
{
text: "Add Reservation", onClick: function (args) {
var selectedRange = dp.multirange.get();
if (selectedRange.length > 0) {
var data = getSelectedDays(selectedRange);
addReservation(data);
}
dp.clearSelection();
}
},
{ text: "-" },
{
text: "Clear selection", onClick: function (args) {
dp.clearSelection();
}
}
]
});
This is effectively the code that is in now and when the dp.multirange.get() is called in a context menu initiated from a range selected with the mouse, there are no issues, but when the dp.multirange.get() is called in a context menu initiated from a range selected with touch, it returns a zero length array.
Comment posted by Dan Letecky [DayPilot] 2 years ago.
Thanks - and what touch device do you use?
Comment posted by Vincent 2 years ago.
Just the mobile simulator in the chrome browser.
Answer posted by Dan Letecky [DayPilot] 2 years ago.
I have one test case where it works fine and one where it doesn’t. I’m still trying to find out what’s going on.
Anyway, the following approach works in both setups:
dp.onTimeRangeSelected = function (args) {
const source = {
calendar: dp,
selection: dp.multirange.get()
};
timerangeContextMenu.show(source);
};
var timerangeContextMenu = new DayPilot.Menu({
items: [
{
text: "Add Reservation", onClick: function (args) {
var selectedRange = source.selection;
if (selectedRange.length > 0) {
var data = getSelectedDays(selectedRange);
addReservation(data);
}
dp.clearSelection();
}
},
{ text: "-" },
{
text: "Clear selection", onClick: function (args) {
dp.clearSelection();
}
}
]
});
Comment posted by Dan Letecky [DayPilot] 2 years ago.
OK, my problem was using dp.multiselect.get() instead of dp.multirange.get().