-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmouseman.js
More file actions
32 lines (24 loc) · 787 Bytes
/
mouseman.js
File metadata and controls
32 lines (24 loc) · 787 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function NullMouseHandler() {
this.handle = function (evt) {console.log("NullMouseHandler." + evt.type);}
};
function MouseMan() {
var state = {
mouseHandler: new NullMouseHandler()
}
this.handle = function(evt) {state.mouseHandler.handle(evt);};
this.setMouseHandler = function(obj) {
if (obj) {
state.mouseHandler = obj;
} else {
state.mouseHandler = new NullMouseHandler();
}
}
this.addListeners = function(obj) {
obj.addEventListener('click', this.handle, false);
obj.addEventListener('mousedown', this.handle, false);
obj.addEventListener('mouseup', this.handle, false);
obj.addEventListener('mouseover', this.handle, false);
obj.addEventListener('mousemove', this.handle, false);
obj.addEventListener('mouseout', this.handle, false);
};
}