[gtk+/broadway: 69/71] [broadway] Hook mousewheel scrolling
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/broadway: 69/71] [broadway] Hook mousewheel scrolling
- Date: Thu, 25 Nov 2010 21:21:04 +0000 (UTC)
commit 667d23aa7c256728526fb261771646168d63a000
Author: Alexander Larsson <alexl redhat com>
Date: Thu Nov 25 21:02:21 2010 +0100
[broadway] Hook mousewheel scrolling
gdk/broadway/broadway.js | 33 +++++++++++++++++++++++++++++++++
1 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/gdk/broadway/broadway.js b/gdk/broadway/broadway.js
index a2fd483..fb20a98 100644
--- a/gdk/broadway/broadway.js
+++ b/gdk/broadway/broadway.js
@@ -293,6 +293,31 @@ function on_mouse_up (ev) {
send_input ("B", [get_surface_id(ev), ev.pageX, ev.pageY, ev.button, ev.timeStamp])
}
+function cancel_event(ev)
+{
+ ev = ev ? ev : window.event;
+ if (ev.stopPropagation)
+ ev.stopPropagation();
+ if (ev.preventDefault)
+ ev.preventDefault();
+ ev.cancelBubble = true;
+ ev.cancel = true;
+ ev.returnValue = false;
+ return false;
+}
+
+function on_mouse_wheel(ev)
+{
+ ev = ev ? ev : window.event;
+ var offset = ev.detail ? ev.detail : ev.wheelDelta;
+ var dir = 0
+ if (offset > 0)
+ dir = 1;
+ send_input ("s", [get_surface_id(ev), ev.pageX, ev.pageY, dir, ev.timeStamp])
+
+ return cancel_event(ev);
+}
+
function connect()
{
var xhr = createXHR();
@@ -325,4 +350,12 @@ function connect()
document.onmousemove = on_mouse_move;
document.onmousedown = on_mouse_down;
document.onmouseup = on_mouse_up;
+
+ if (document.addEventListener) {
+ document.addEventListener('DOMMouseScroll', on_mouse_wheel, false);
+ document.addEventListener('mousewheel', on_mouse_wheel, false);
+ } else if (document.attachEvent) {
+ element.attachEvent("onmousewheel", on_mouse_wheel);
+ }
+
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]