search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Capture global mousedown/up event

Asked by Simon
10 years ago.

I need to capture any mousedown and mouseup event fired on the scheduler.

I've tried just adding an eventlistener to the entire dps container like this:
$("#dps")[0].addEventListener("mousedown", function () { /*TODO*/ });

This works if I press anything but (daypilot)events. When I press the mouse on (daypilot)events the mousedown event won't fire.

How can all mousedown and mouseup events be captured on the scheduler?
The reason I need this behavior is because I need to prevent certain commandCallbacks when a user is interacting (moving or resizing evetns etc.) with the scheduler.

Comment posted by Dan Letecky [DayPilot]
10 years ago.

It's not possible to hook the mousedown and mouseup events on the scheduler div reliably because it is usually consumed by the internal handlers.

However, it might be possible to add an event for the start and end of drag and drop interaction - this is already tracked by the scheduler for similar reasons (to prevent autorefresh and other activities).

Comment posted by Simon
10 years ago.

Ok thanks.

I've tried experimenting with intercepting the dragstart and dragstop events without any success so far. I've looked at "External Drag and Drop" documentation ( http://doc.daypilot.org/scheduler/external-drag-and-drop/ ) but that's not exactly what I want.

I want to get notified when any dragstart and dragstop events occur regardless of their origin (external/internal).

The reason I need this is because:
When an event is saved, clients will get notified by signalR that the scheduler needs to be refreshed. So if a user is NOT interacting with the scheduler, a commandCallback should be fired to refresh the scheduler.

Instead of getting notified when drag events occur I've also tried implementing the "is user interacting" check you mentioned like so:
// skip if an operation is active
if (!DayPilotScheduler.resizing && !DayPilotScheduler.moving && !DayPilotScheduler.drag && !DayPilotScheduler.range) {
(copied from daypilot-scheduler.src.js _doRefresh).

But the resizing, moving, drag and range members are all undefined a the momemt when I try access them.
Is there some other way of accessing the information provided by the DayPilotScheduler object?

Or is there an easier way to detect when a user is interacting with the scheduler?

Comment posted by Simon
10 years ago.

Any suggestions?
I just need a way to prevent any commandCallbacks from being invoked (clientside) when a mousedown has occured.

Comment posted by Dan Letecky [DayPilot]
10 years ago.

Hi Simon,

I'm working on a set of events that will allow you to do this. onInteractionStart/onInteractionEnd will be fired at the beginning and end of user drag and drop interaction (event moving, event resizing, time range selecting). I will let you know as soon as it is implemented.

Comment posted by Simon
10 years ago.

Sounds perfect. Thanks!

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.