Doublelick, Dragged
clovis2

Hello!

 

Is it any way (in Wade) to catch a double click event? Same thing for dragged event (to avoid abundance of mouseMove events).

 

Thanks

All 4 Comments
Gio

Hi

 

There isn't a built-in double click event, though it's definitely something that we could add in the near future. In the meantime, you could easily emulate it with a bit of code.

 

A double click is defined as a mouseDown event following a mouseUp event within a short time (typically about 0.5 seconds). So you could do this for the object that you want to detect double clicks:

myObject.mouseUpTime = 0;myObject.onMouseUp = function(){    this.mouseUpTime = wade.getAppTime();};myObject.onMouseDown = function(){    if (wade.getAppTime() - this.mouseUpTime < 0.5)    {         // double click detected, do something here    }};

Obviously for this to work, your object must be listening for both onMouseUp and onMouseDown events (which it does automatically if you add it to the scene with wade.addSceneObject(myObject, true);

 

I am not sure what you mean by dragged event, could you make an example?

clovis2

Hello,

 

Thanks for your answer.

A mouseDragged event is as a mouseMoved one except it occurs only when mouse button is down. The advantage is not to be invaded by mouseMoved ones when mouse button is up.

Here is a reference for mouse events for Mac: https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/EventOverview/HandlingMouseEvents/HandlingMouseEvents.html.

Gio

I wasn't aware of that. I'll add it to the list of things to add to WADE.

 

Would this work in the meantime?

myObject.onMouseMove = function(){    if (wade.isMouseDown())    {         // dragged event    }    else    {         // mouse move without pressing the mouse button    }};
clovis2

I'll try it as soon I go back to Wade. It seems to be fine.

Post a reply
Add Attachment
Submit Reply
Login to Reply