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

Source Code for Module pyjamas.ui.MultiListener

 1   
 2   
3 -class MultiListener(object):
4 combinations = dict( 5 onFocus = ["onLostFocus"], 6 onLostFocus = ["onFocus"], 7 onKeyDown = ["onKeyUp", "onKeyPress"], 8 onKeyUp = ["onKeyPress", "onKeyDown"], 9 onKeyPress = ["onKeyDown", "onKeyUp"], 10 onMouseMove = ["onMouseDown","onMouseUp","onMouseEnter","onMouseLeave"], 11 onMouseDown = ["onMouseUp","onMouseEnter","onMouseLeave","onMouseMove"], 12 onMouseUp = ["onMouseEnter","onMouseLeave","onMouseMove","onMouseDown"], 13 onMouseEnter = ["onMouseLeave","onMouseMove","onMouseDown","onMouseUp"], 14 onMouseLeave = ["onMouseMove","onMouseDown","onMouseUp","onMouseEnter"], 15 ) 16
17 - def __init__(self, obj, **kwargs):
18 self.set(obj, **kwargs)
19
20 - def set(self, obj, **kwargs):
21 ignore = getattr(self, "ignore") 22 for k, v in kwargs.iteritems(): 23 setattr(self, k, getattr(obj, v)) 24 if k in self.combinations: 25 for k1 in self.combinations[k]: 26 if not hasattr(self, k1): 27 setattr(self, k1, ignore)
28
29 - def ignore(self, *args, **kwargs):
30 pass
31