Click = mousedown followed by mouseup

29 January 2015 01:02
This may be a simple js question. I have an app with and traget camera and multiple selectable objects, but I want users to be able to move the camera without accidentally selecting objects and thus triggering functions.

I have been temporarily using the mouseup event in the following code:

canvas_elem.addEventListener("mouseup", main_canvas_click, false);

After looking in the app.js module i noticed that a"click" event was equal to a mouseup event. My issue is that I need a "click" event to equal onmousedown followed by onmouveup, otherwise accidentally releasing the mouse over an object would trigger a function. Everything I try doesn't seem to work, any suggestions.
29 January 2015 10:55
My issue is that I need a "click" event to equal onmousedown followed by onmouseup
As I can tell the only way to solve this task is to check how much time has passed since mousedown event. If this value is less than some delta and mouseup is being called it means you can perform needed actions.
To receive time value you need to call main.global_timeline() function.
13 March 2018 23:21
There is a more simple solution:

You can easily detect a mouseup using a logic function in your CT_TRIGGER or CT_CONTINUOUS type sensor manifold.

A simple snippet:

function registerMouse() {
  console.log("mouse registered");
  var clickSensor = m_ctl.create_mouse_click_sensor();

  function logic(triggers) {
   if (triggers[0])
    return 1;
    return 0;

  function cb(obj, id, pulse, param) {


Its pulse will be -1 on every mouseup event. To understand how it works check out the API documentation of m_ctl.CT_CONTINUOUS and m_ctl.create_mouse_click_sensor()… oh wait the m_ctl.create_mouse_click_sensor() documentation does not say a word how its sensor interfaces with the manifold via the logic function, however that is the key.
Please register or log in to leave a reply.