Home | Trees | Indices | Help |
|
---|
|
1 # Copyright 2006 James Tauber and contributors 2 # Copyright (C) 2009 Luke Kenneth Casson Leighton <lkcl@lkcl.net> 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); 5 # you may not use this file except in compliance with the License. 6 # You may obtain a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, 12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 # See the License for the specific language governing permissions and 14 # limitations under the License. 15 from pyjamas import DOM 16 from pyjamas.ui import Event 17 from pyjamas.EventController import Handler 1820 x = DOM.eventGetClientX(event) - DOM.getAbsoluteLeft(sender.getElement()) 21 y = DOM.eventGetClientY(event) - DOM.getAbsoluteTop(sender.getElement()) 22 23 etype = DOM.eventGetType(event) 24 if etype == "mousedown": 25 for listener in listeners: 26 listener.onMouseDown(sender, x, y) 27 return True 28 elif etype == "mouseup": 29 for listener in listeners: 30 listener.onMouseUp(sender, x, y) 31 return True 32 elif etype == "mousemove": 33 for listener in listeners: 34 listener.onMouseMove(sender, x, y) 35 return True 36 elif etype == "mouseover": 37 to_element = DOM.eventGetToElement(event) 38 if to_element and not DOM.isOrHasChild(sender.getElement(), to_element): 39 for listener in listeners: 40 listener.onMouseEnter(sender) 41 return True 42 elif etype == "mouseout": 43 to_element = DOM.eventGetToElement(event) 44 if to_element and not DOM.isOrHasChild(sender.getElement(), to_element): 45 for listener in listeners: 46 listener.onMouseLeave(sender) 47 return True 48 return False49 50 MOUSE_EVENTS = [ "mousedown", "mouseup", "mousemove", "mouseover", "mouseout"] 51539455 56 self._mouseListeners = [] 57 self._mousePreventDefault = preventDefault 58 self.sinkEvents( Event.MOUSEEVENTS )5961 etype = DOM.eventGetType(event) 62 if etype in MOUSE_EVENTS: 63 if self._mousePreventDefault: 64 DOM.eventPreventDefault(event) 65 return fireMouseEvent(self._mouseListeners, self, event) 66 return False6769 self._mouseListeners.append(listener)7072 self._mouseListeners.remove(listener)73 76 79 82 85 88 919612198 99 self._mouseWheelListeners = [] 100 self._mouseWheelPreventDefault = preventDefault 101 self.sinkEvents( Event.ONMOUSEWHEEL )102104 etype = DOM.eventGetType(event) 105 if etype == "mousewheel": 106 if self._mouseWheelPreventDefault: 107 DOM.eventPreventDefault(event) 108 velocity = DOM.eventGetMouseWheelVelocityY(event) 109 for listener in self._mouseWheelListeners: 110 listener.onMouseWheel(self, velocity) 111 return True112114 self._mouseWheelListeners.append(listener)115117 self._mouseWheelListeners.remove(listener)118
Home | Trees | Indices | Help |
|
---|
http://epydoc.sourceforge.net |