1 """
2 Copyright (C) 2008, 2009 - Luke Kenneth Casson Leighton <lkcl@lkcl.net>
3
4 """
5 from pyjamas import DOM
6 from pyjamas.ui import Event
7
9
10 - def __init__(self, preventDefault=False):
17
20
23
25 self._doubleclickListeners.append(listener)
26
28 self._clickListeners.append(listener)
29
31 """Listen to events raised by the browser and call the appropriate
32 method of the listener (widget, ..) object.
33 """
34 type = DOM.eventGetType(event)
35 if type == "click":
36 if self._clickPreventDefault:
37 DOM.eventPreventDefault(event)
38 for listener in self._clickListeners:
39 if hasattr(listener, "onClick"):
40 listener.onClick(self)
41 else:
42 listener(self)
43 elif type == "dblclick":
44 if self._clickPreventDefault:
45 DOM.eventPreventDefault(event)
46 for listener in self._doubleclickListeners:
47 if hasattr(listener, "onDoubleClick"):
48 listener.onDoubleClick(self)
49 else:
50 listener(self)
51
53 self._clickListeners.remove(listener)
54
56 self._doubleclickListeners.remove(listener)
57