Bugzilla – Attachment 481 Details for
Bug 4666
Difficult to "double click" with HTML5 client on iPad
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Allow for double click to happen even if the second click is a slight bit off
doubleclick_v2.patch (text/plain), 1.94 KB, created by
Samuel Mannehed
on 2013-06-25 18:26:19 CEST
(
hide
)
Description:
Allow for double click to happen even if the second click is a slight bit off
Filename:
MIME Type:
Creator:
Samuel Mannehed
Created:
2013-06-25 18:26:19 CEST
Size:
1.94 KB
patch
obsolete
>diff --git a/include/input.js b/include/input.js >index b996c7d..05d05f1 100644 >--- a/include/input.js >+++ b/include/input.js >@@ -1,6 +1,7 @@ > /* > * noVNC: HTML5 VNC client > * Copyright (C) 2012 Joel Martin >+ * Copyright (C) 2013 Samuel Mannehed for Cendio AB > * Licensed under MPL 2.0 or any later version (see LICENSE.txt) > */ > >@@ -489,6 +490,9 @@ var that = {}, // Public API methods > conf = {}, // Configuration attributes > mouseCaptured = false; > >+var doubleClickTimer = null, >+ lastClickPos = null; >+ > // Configuration attributes > Util.conf_defaults(conf, that, defaults, [ > ['target', 'ro', 'dom', document, 'DOM element that captures mouse input'], >@@ -521,6 +525,10 @@ function releaseMouse() { > // Private functions > // > >+function resetDoubleClickTimer() { >+ doubleClickTimer = null; >+} >+ > function onMouseButton(e, down) { > var evt, pos, bmask; > if (! conf.focused) { >@@ -528,6 +536,28 @@ function onMouseButton(e, down) { > } > evt = (e ? e : window.event); > pos = Util.getEventPosition(e, conf.target, conf.scale); >+ >+ // When two clicks occur within 500 ms of each other and are >+ // closer than 50 pixels together a double click is triggered. >+ if (down == 1) { >+ if (doubleClickTimer == null) { >+ lastClickPos = pos; >+ } else { >+ clearTimeout(doubleClickTimer); >+ >+ var xs = lastClickPos.x - pos.x; >+ var ys = lastClickPos.y - pos.y; >+ var d = Math.sqrt((xs * xs) + (ys * ys)); >+ >+ // When the distance between the two clicks is less than 50 pixels >+ // force the position of the latter click to the position of the first >+ if (d < 50) { >+ pos = lastClickPos; >+ } >+ } >+ doubleClickTimer = setTimeout(resetDoubleClickTimer, 500); >+ } >+ > if (e.touches || e.changedTouches) { > // Touch device > bmask = conf.touchButton;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 4666
: 481