Package library :: Package pyjamas :: Package ui :: Module Event
[hide private]
[frames] | no frames]

Source Code for Module library.pyjamas.ui.Event

 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   
16  """ 
17      This module contains flags and integer values used by the event system. 
18  """ 
19   
20  BUTTON_LEFT   = 1 
21  BUTTON_MIDDLE = 4 
22  BUTTON_RIGHT  = 2 
23   
24  ONBLUR        = 0x01000 
25  ONCHANGE      = 0x00400 
26  ONCLICK       = 0x00001 
27  ONCONTEXTMENU = 0x20000 
28  ONDBLCLICK    = 0x00002 
29  ONERROR       = 0x10000 
30  ONFOCUS       = 0x00800 
31  ONKEYDOWN     = 0x00080 
32  ONKEYPRESS    = 0x00100 
33  ONKEYUP       = 0x00200 
34  ONLOAD        = 0x08000 
35  ONLOSECAPTURE = 0x02000 
36  ONMOUSEDOWN   = 0x00004 
37  ONMOUSEMOVE   = 0x00040 
38  ONMOUSEOUT    = 0x00020 
39  ONMOUSEOVER   = 0x00010 
40  ONMOUSEUP     = 0x00008 
41  ONMOUSEWHEEL  = 0x40000 
42  ONSCROLL      = 0x04000 
43  ONINPUT       = 0x80000 
44  DRAGEVENTS    = 0x100000 
45  DROPEVENTS    = 0x200000 
46   
47  FOCUSEVENTS   = 0x01800 # ONFOCUS | ONBLUR 
48  KEYEVENTS     = 0x00380 # ONKEYDOWN | ONKEYPRESS | ONKEYUP 
49  MOUSEEVENTS   = 0x0007C # ONMOUSEDOWN | ONMOUSEUP | ONMOUSEMOVE | ONMOUSEOVER | ONMOUSEOUT 
50   
51  eventbits = { 
52      # bit    :  name, sinkEvents 
53      0x000001 : ("click", ["click"]), 
54      0x000002 : ("dblclick", ["dblclick"]), 
55      0x000004 : ("mousedown", ["mousedown"]), 
56      0x000008 : ("mouseup", ["mouseup"]), 
57      0x000010 : ("mouseover", ["mouseover"]), 
58      0x000020 : ("mouseout", ["mouseout"]), 
59      0x000040 : ("mousemove", ["mousemove"]), 
60      0x000080 : ("keydown", ["keydown"]), 
61      0x000100 : ("keypress", ["keypress"]), 
62      0x000200 : ("keyup", ["keyup"]), 
63      0x000400 : ("change", ["change"]), 
64      0x000800 : ("focus", ["focus"]), 
65      0x001000 : ("blur", ["blur"]), 
66      0x002000 : ("losecapture", ["losecapture"]), 
67      0x004000 : ("scroll", ["scroll"]), 
68      0x008000 : ("load", ["load"]), 
69      0x010000 : ("error", ["error"]), 
70      0x020000 : ("contextmenu", ["contextmenu"]), 
71      0x040000 : ("mousewheel", ["mousewheel"]), 
72      0x080000 : ("input", ["input"]), 
73      0x100000 : ("dragevents", ["drag", "dragstart", "dragend"]), 
74      0x200000 : ("dropevents", ["drop", "dragenter", "dragover", "dragleave"]), 
75  } 
76  # eventmap will be filled in init(), but some names 
77  # will be added manually for interoperability 
78  # (duplicate names for bit) 
79  eventmap = { 
80      "mousewheel": 0x040000, 
81      "mousescroll": 0x040000, 
82      "DOMMouseScroll": 0x040000, 
83      "input": 0x080000, 
84      "propertychange": 0x080000, 
85  } 
86   
87 -def _create_eventmap():
88 for bit, bitmap in eventbits.iteritems(): 89 eventmap[bitmap[0]] = bit
90
91 -def init():
92 _create_eventmap()
93 94 init() 95