PageRenderTime 4ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 2ms app.codeStats 0ms

/pyjs/tests/test012.py

http://pyjamas.googlecode.com/
Python | 25 lines | 20 code | 5 blank | 0 comment | 4 complexity | 26b3097617196ab3f5eb1a796a6b113b MD5 | raw file
 1import DOM
 2
 3class Widget:
 4
 5    def __init__(self):
 6        self.attached = False
 7
 8    def setParent(self, parent):
 9        self.parent = parent
10        if parent == None:
11            self.onDetach()
12        elif parent.attached:
13            self.onAttach()
14
15    def onAttach(self):
16        if self.attached:
17            return
18        self.attached = True
19        DOM.setEventListener(self.getElement(), self)
20        
21    def onDetach(self):
22        if not self.attached:
23            return
24        self.attached = False
25        DOM.setEventListener(self.getElement(), None)