If mouse is not working in chrome...

5,395 views
Skip to first unread message

Tim Müller

unread,
May 28, 2014, 4:57:17 PM5/28/14
to no...@googlegroups.com
Hello.

I searched hours to find the solution myself and want to save your time.

So if you thinking noVNC does not work in chrome with the cursor / mouse but keyboard events work: think about if you have a touch-monitor.
I have one, but did not thought that this could be the problem and dont event tried id with touch until yet.

The thing is: if there is a touch-monitor and a compatible browser (chrome) than the 'ontouchstart'-event and all other touch-events works. BUT this causes to ignore normal mouse-events because this snipped in input.js line 353:

 if ('ontouchstart' in document.documentElement) {
        Util.addEvent(c, 'touchstart', onMouseDown);
        Util.addEvent(window, 'touchend', onMouseUp);
        Util.addEvent(c, 'touchend', onMouseUp);
        Util.addEvent(c, 'touchmove', onMouseMove);
    } else {
        Util.addEvent(c, 'mousedown', onMouseDown);
        Util.addEvent(window, 'mouseup', onMouseUp);
        Util.addEvent(c, 'mouseup', onMouseUp);
        Util.addEvent(c, 'mousemove', onMouseMove);
        Util.addEvent(c, (Util.Engine.gecko) ? 'DOMMouseScroll' : 'mousewheel',
                onMouseWheel);
  }

As i saw this code i realized it.

Greets.

Luke Kende

unread,
May 29, 2014, 1:23:28 PM5/29/14
to no...@googlegroups.com
I narrowed this down as well.  Not the actual code segment that you isolated but that certain cases where novnc is seeing the browser as a touch screen and hence mouse clicks were ignored.

Any suggestion on how to correct this?  Maybe remove the logic statements and let all events get registered to the listeners?  Just haven't had time to test possible solutions.

Joel Martin

unread,
May 29, 2014, 6:31:01 PM5/29/14
to no...@googlegroups.com
Luke and Tim,

It's been a long time since I implemented that, but I have a vague recollection that on touch only devices, both mouse events and touch events are generated which makes things a bit hairy. But my memory is getting pretty fuzzy now so I could be wrong.


Luke Kende

unread,
May 29, 2014, 6:39:55 PM5/29/14
to no...@googlegroups.com
Joel,

Thanks for responding.  That makes sense that it would be hairy.  Is there an api method on RFB.get_mouse()  that could change that.  I have some browsers like Win 8 report itself as touchscreen but the user is actually using a mouse.  Theoretically, I could check for device type and browser and reset this if there's an exposed method... or I could write one into it if not.

Hamilton Turner

unread,
Sep 19, 2014, 1:23:49 PM9/19/14
to no...@googlegroups.com
https://github.com/kanaka/noVNC/pull/394 may be of interest to this thread

Leonardo Reiter

unread,
Jan 14, 2015, 11:12:57 AM1/14/15
to no...@googlegroups.com
I found that with this patch I can use both the mouse and the touchscreen interchangeably:

diff --git a/include/input.js b/include/input.js
index 5d9e209..1ade49a 100644
--- a/include/input.js
+++ b/include/input.js
@@ -337,14 +337,13 @@ var Keyboard, Mouse;
                 Util.addEvent(window, 'touchend', this._eventHandlers.mouseup);
                 Util.addEvent(c, 'touchend', this._eventHandlers.mouseup);
                 Util.addEvent(c, 'touchmove', this._eventHandlers.mousemove);
-            } else {
-                Util.addEvent(c, 'mousedown', this._eventHandlers.mousedown);
-                Util.addEvent(window, 'mouseup', this._eventHandlers.mouseup);
-                Util.addEvent(c, 'mouseup', this._eventHandlers.mouseup);
-                Util.addEvent(c, 'mousemove', this._eventHandlers.mousemove);
-                Util.addEvent(c, (Util.Engine.gecko) ? 'DOMMouseScroll' : 'mous
-                              this._eventHandlers.mousewheel);
             }
+           Util.addEvent(c, 'mousedown', this._eventHandlers.mousedown);
+           Util.addEvent(window, 'mouseup', this._eventHandlers.mouseup);
+           Util.addEvent(c, 'mouseup', this._eventHandlers.mouseup);
+           Util.addEvent(c, 'mousemove', this._eventHandlers.mousemove);
+           Util.addEvent(c, (Util.Engine.gecko) ? 'DOMMouseScroll' : 'mousewhee
+                              this._eventHandlers.mousewheel);

             /* Work around right and middle click browser behaviors */
             Util.addEvent(document, 'click', this._eventHandlers.mousedisable);

I've tested on IE 11 and the latest Chrome on 64-bit Windows 8.1, as well as Chrome on Android 5 (touch only), without issues.

Any thoughts on this?

Thanks,
Leo Reiter

Luke Kende

unread,
Jan 14, 2015, 11:24:38 AM1/14/15
to no...@googlegroups.com
Looks good to me.  If one event handler does not interfere with another, then you could prob just always add both touch and mouse events.  I ended up doing something similar, basically removing touch events and always adding mouse events since we don't support novnc on touch devices.

--
You received this message because you are subscribed to a topic in the Google Groups "noVNC" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/novnc/bOpKeuZCd7s/unsubscribe.
To unsubscribe from this group and all its topics, send an email to novnc+un...@googlegroups.com.
To post to this group, send email to no...@googlegroups.com.
Visit this group at http://groups.google.com/group/novnc.
For more options, visit https://groups.google.com/d/optout.

Gary Mulder

unread,
Feb 10, 2015, 6:40:20 PM2/10/15
to no...@googlegroups.com
On Wednesday, 14 January 2015 16:12:57 UTC, Leonardo Reiter wrote:
I found that with this patch I can use both the mouse and the touchscreen interchangeably:

I came across this thread while trying to get noVNC running on my touch-enabled Chrome OS laptop...

 I manually patched input.js with the above patch and now curiously my touch screen works fine inside the noVNC window to control the mouse pointer, and the laptop's mouse works outside the noVNC window.

Any suggestions?

Regards,
Gary

Gary Mulder

unread,
Feb 10, 2015, 7:19:05 PM2/10/15
to no...@googlegroups.com
Sorry, ignore the last. Working now. I can finally can use my Chromebook as a thin client.

Thanks!
Gary


Wolken Gutierrez

unread,
Apr 4, 2017, 5:09:55 PM4/4/17
to noVNC
Hey guys, I'm having the same issue with my touch-enabled laptop.

Can anyone point me in the direction of how to apply this patch?

Thx,

Wolken 

sam...@cendio.com

unread,
Apr 5, 2017, 2:27:50 AM4/5/17
to noVNC
What is the commit hash of the version you are using? The patch is applied on master.
Reply all
Reply to author
Forward
0 new messages