DayPilot Knowledge Base

AJAX Calendar/Scheduling Controls
DayPilot Pro (AJAX Calendar Control)
» DayPilot ASP.NET Calendar
DayPilot Pro (AJAX Monthly Calendar Control)
» DayPilot ASP.NET Monthly Calendar
DayPilot Pro (AJAX Scheduler Control)
» DayPilot ASP.NET Scheduler
DayPilot » Knowledge Base » How to detect time offset of mouse clicks inside an event

How to detect time offset of mouse clicks inside an event

Last revision: Feb 10, 2010

The current mouse position offset (relative to the event upper-left corner) is stored in dps.eventOffset property.

Example (context menu)

The following code show the relative mouse coordinates after the context menu item is clicked:

<DayPilot:MenuItem Action="JavaScript" JavaScript="alert('x:' + dps.eventOffset.x + ' y:' + dps.eventOffset.y + ' resource:' + e.row());" Text="Mouse offset (relative to event)" />

Calculating the time offset

In order to get the time position that was clicked, you should use a simple calculation involving e.start() as event start position, dps.cellDuration and dps.cellWidth.

Example

var x = dps.eventOffset.x;
var time = e.start().addMinutes(x/dps.cellWidth * dps.cellDuration);

Please note that such a simple calculation only works for continuous timeline (no columns are hidden using ShowNonBusiness="false").

Controls: Scheduler

Related

How to get the scrollbar position as date/time (client side)
How to implement Copy & Paste in the Calendar
How to get the scrollbar position as date/time (server side)
How to open an event edit dialog from a context menu (Calendar)