W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2011

Mouse Lock

From: Vincent Scheib <scheib@google.com>
Date: Thu, 16 Jun 2011 15:21:56 -0700
Message-ID: <BANLkTinV0oMZ1yE4ctVx5ZYsZgjZfZLEzgb8eFWETHBQ4VKmow@mail.gmail.com>
To: Brandon Andrews <warcraftthreeft@sbcglobal.net>
Cc: "Gregg Tavares (wrk)" <gman@google.com>, Glenn Maynard <glenn@zewt.org>, Charles Pritchard <chuck@jumis.com>, Kenneth Russell <kbr@google.com>, robert@ocallahan.org, public-webapps@w3.org
[Building on the "Mouse Capture for Canvas" thread:
http://lists.w3.org/Archives/Public/public-webapps/2011JanMar/thread.html#msg437
 ]

I'm working on an implementation of mouse lock in Chrome, and would
appreciate collaboration on refinement of the spec proposal. Hopefully
webapps is willing to pick up this spec work? I'm up for helping write the
draft.

Some updates from Sirisian's Comment 12 on the w3 bug (
http://www.w3.org/Bugs/Public/show_bug.cgi?id=9557#c12):
- We shouldn't need events for success/failure to obtain lock, those can be
callbacks similar to geolocation API: (
http://dev.w3.org/geo/api/spec-source.html#geolocation_interface).

My short summary is then:
- 2 new methods on an element to enter and exit mouse lock. Two callbacks on
the entering call provide notification of success or failure.
- Mousemove event gains .deltaX .deltaY members, always valid, not just
during mouse lock.
- Elements have an event to detect when mouseLock is lost.

Example
x = document.getElementById("x");
x.addEventListener("mousemove", mouseMove);
x.addEventListener("mouseLockLost", mouseLockLost);
x.lockMouse(
  function() { console.log("Locked."); },
  function() { console.log("Lock rejected."); } );
function mouseMove(e) { console.log(e.deltaX + ", " + e.deltaY); }
function mouseLockLost(e) { console.log("Lost lock."); }
Received on Sunday, 19 June 2011 00:11:24 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:45 GMT