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 1719 x = DOM.eventGetClientX(event) - DOM.getAbsoluteLeft(sender.getElement()) 20 y = DOM.eventGetClientY(event) - DOM.getAbsoluteTop(sender.getElement()) 21 22 type = DOM.eventGetType(event) 23 if type == "mousedown": 24 for listener in listeners: 25 listener.onMouseDown(sender, x, y) 26 elif type == "mouseup": 27 for listener in listeners: 28 listener.onMouseUp(sender, x, y) 29 elif type == "mousemove": 30 for listener in listeners: 31 listener.onMouseMove(sender, x, y) 32 elif type == "mouseover": 33 from_element = DOM.eventGetFromElement(event) 34 if not DOM.isOrHasChild(sender.getElement(), from_element): 35 for listener in listeners: 36 listener.onMouseEnter(sender) 37 elif type == "mouseout": 38 to_element = DOM.eventGetToElement(event) 39 if not DOM.isOrHasChild(sender.getElement(), to_element): 40 for listener in listeners: 41 listener.onMouseLeave(sender)42 43 MOUSE_EVENTS = [ "mousedown", "mouseup", "mousemove", "mouseover", "mouseout"] 44468048 49 self._mouseListeners = [] 50 self._mousePreventDefault = preventDefault 51 self.sinkEvents( Event.MOUSEEVENTS )5254 type = DOM.eventGetType(event) 55 if type in MOUSE_EVENTS: 56 if self._mousePreventDefault: 57 DOM.eventPreventDefault(event) 58 fireMouseEvent(self._mouseListeners, self, event)5961 self._mouseListeners.append(listener)6264 self._mouseListeners.remove(listener)65 68 71 74 77
Home | Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Wed Jun 16 12:42:31 2010 | http://epydoc.sourceforge.net |