Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #8346 > unrolled thread

detecting !mouse

Started byAndrew Poulos <ap_prog@hotmail.com>
First post2011-11-15 14:07 +1100
Last post2011-11-16 13:53 +1100
Articles 6 — 4 participants

Back to article view | Back to comp.lang.javascript


Contents

  detecting !mouse Andrew Poulos <ap_prog@hotmail.com> - 2011-11-15 14:07 +1100
    Re: detecting !mouse Andrew Poulos <ap_prog@hotmail.com> - 2011-11-15 16:42 +1100
      Re: detecting !mouse Swifty <steve.j.swift@gmail.com> - 2011-11-15 10:54 +0000
    Re: detecting !mouse Gregor Kofler <usenet@gregorkofler.com> - 2011-11-15 11:04 +0100
    Re: detecting !mouse RobG <rgqld@iinet.net.au> - 2011-11-15 22:45 +1000
      Re: detecting !mouse Andrew Poulos <ap_prog@hotmail.com> - 2011-11-16 13:53 +1100

#8346 — detecting !mouse

FromAndrew Poulos <ap_prog@hotmail.com>
Date2011-11-15 14:07 +1100
Subjectdetecting !mouse
Message-ID<fu6dnREJhvYbSlzTnZ2dnUVZ_g-dnZ2d@westnet.com.au>
Ok, I can't user window.touch, or its variants, to confidentially 
determine if a device is actually touch capable. But would it be safe to 
assume that a device that returns 0 for
   event.clientX || e.pageX, and event.clientY || e.pageY
does *not* have a mouse attached?

Andrew Poulos

[toc] | [next] | [standalone]


#8347

FromAndrew Poulos <ap_prog@hotmail.com>
Date2011-11-15 16:42 +1100
Message-ID<0fWdnXRq6tVaZlzTnZ2dnUVZ_t-dnZ2d@westnet.com.au>
In reply to#8346
On 15/11/2011 2:07 PM, Andrew Poulos wrote:
> Ok, I can't user window.touch, or its variants, to confidentially
> determine if a device is actually touch capable. But would it be safe to
> assume that a device that returns 0 for
> event.clientX || e.pageX, and event.clientY || e.pageY
> does *not* have a mouse attached?

Yes if the cursor was at 0, 0 then event.clientX etc would correctly 
return 0 but how likely is it that the cursor is at 0, 0?

Andrew Poulos

[toc] | [prev] | [next] | [standalone]


#8349

FromSwifty <steve.j.swift@gmail.com>
Date2011-11-15 10:54 +0000
Message-ID<mtg4c793ds86ak9jd01uaucloc8cv6gq7g@4ax.com>
In reply to#8347
On Tue, 15 Nov 2011 16:42:24 +1100, Andrew Poulos
<ap_prog@hotmail.com> wrote:

>but how likely is it that the cursor is at 0, 0?

In my case, quite likely. For contractual reasons my system is set to
lock the desktop after at most 30 minutes of inactivity. I'm not keen
on this.

So I have an application which, if it has detected no mouse/keybpard
activity for 25 minutes, moves the mouse to (0,0) and does a Button #1
click.

It has to be an addressable point, so (0,0) is about the only logical
choice. A click there is unlikely to do any damage (in my case it's
never done anything)

But this does mean that my mouse pointer is quite likely to be at
(0,0)

Incidentally, I have no particular interest in this thread, but the
reference to (0,0) caught my eye.

-- 
Steve Swift
http://www.swiftys.org.uk/swifty.html
http://www.ringers.org.uk

[toc] | [prev] | [next] | [standalone]


#8348

FromGregor Kofler <usenet@gregorkofler.com>
Date2011-11-15 11:04 +0100
Message-ID<j9tdg7$5bm$1@dont-email.me>
In reply to#8346
Am 2011-11-15 04:07, schrieb Andrew Poulos:
> Ok, I can't user window.touch, or its variants, to confidentially
> determine if a device is actually touch capable. But would it be safe to
> assume that a device that returns 0 for
> event.clientX || e.pageX, and event.clientY || e.pageY
> does *not* have a mouse attached?

Nope. Since without mouse attached, my cursor sits in the middle of the 
screen. And since even the GUI doesn't care (or actively detect) whether 
a mouse is attached or not, I can't see any chances to do this in a 
browser environment.

What would you do, if the user (re-)attaches the mouse?

Gregor

[toc] | [prev] | [next] | [standalone]


#8350

FromRobG <rgqld@iinet.net.au>
Date2011-11-15 22:45 +1000
Message-ID<wuidnVSChY2Uwl_TnZ2dnUVZ_gednZ2d@westnet.com.au>
In reply to#8346
On 15/11/11 1:07 PM, Andrew Poulos wrote:
> Ok, I can't user window.touch, or its variants, to confidentially
> determine if a device is actually touch capable. But would it be safe to
> assume that a device that returns 0 for
> event.clientX || e.pageX, and event.clientY || e.pageY
> does *not* have a mouse attached?

Not sure it's safe to assume that because the cursor reports its 
position as (0,0) at some random instant in time that the device doesn't 
have a mouse attached and therefore suports touch events.

Actually it's quite a leap of faith.

Just because a device supports touch events doesn't mean that no mouse 
(or other pointing device) is attached, or that the user is only using 
touch events. What about keyboard navigation?

A much better strategy is to test for touch support explicitly. Some 
time ago (years) I wrote the following:

    function touchSupported() {
      if (document && document.createEvent) {
        try {
          document.createEvent('TouchEvent');
          return true;
        } catch (e) {
          return false;
        }
      }
    }

but have since lost interest in writing touch-specific scripts. Use it 
at your peril. Maybe there is something in DM's MyLibrary?


-- 
Rob

[toc] | [prev] | [next] | [standalone]


#8364

FromAndrew Poulos <ap_prog@hotmail.com>
Date2011-11-16 13:53 +1100
Message-ID<Vs2dnTUCnZ4GuF7TnZ2dnUVZ_sydnZ2d@westnet.com.au>
In reply to#8350
On 15/11/2011 11:45 PM, RobG wrote:
> On 15/11/11 1:07 PM, Andrew Poulos wrote:
>> Ok, I can't user window.touch, or its variants, to confidentially
>> determine if a device is actually touch capable. But would it be safe to
>> assume that a device that returns 0 for
>> event.clientX || e.pageX, and event.clientY || e.pageY
>> does *not* have a mouse attached?
>
> Not sure it's safe to assume that because the cursor reports its
> position as (0,0) at some random instant in time that the device doesn't
> have a mouse attached and therefore suports touch events.
>
> Actually it's quite a leap of faith.
>
> Just because a device supports touch events doesn't mean that no mouse
> (or other pointing device) is attached, or that the user is only using
> touch events. What about keyboard navigation?
>
> A much better strategy is to test for touch support explicitly. Some
> time ago (years) I wrote the following:
>
> function touchSupported() {
> if (document && document.createEvent) {
> try {
> document.createEvent('TouchEvent');
> return true;
> } catch (e) {
> return false;
> }
> }
> }

My desktop computer (non touch-capable) returns false and my ipad and 
Android phone both return true. So, so far so good.

> but have since lost interest in writing touch-specific scripts. Use it
> at your peril. Maybe there is something in DM's MyLibrary?

Thanks, I didn't notice anything in DM's library.

If a device supports touch events does that also include swipes ie. 
single-finger gestures? Or are swipes considered gestures?

Andrew Poulos

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web