<s> from pyjamas import DOM <EOL> from pyjamas . ui import Event <EOL> def fireChangeEvent ( listeners , sender , event ) : <EOL> etype = DOM . eventGetType ( event ) <EOL> if etype != "<STR_LIT>" : <EOL> return <EOL> for listener in listeners : <EOL> if hasattr ( listener , '<STR_LIT>' ) : <EOL> listener . onChange ( sender ) <EOL> else : <EOL> listener ( sender ) <EOL> class ChangeHandler ( object ) : <EOL> def __init__ ( self ) : <EOL> self . _changeListeners = [ ] <EOL> self . sinkEvents ( Event . ONCHANGE ) <EOL> def onBrowserEvent ( self , event ) : <EOL> etype = DOM . eventGetType ( event ) <EOL> if etype == '<STR_LIT>' : <EOL> fireChangeEvent ( self . _changeListeners , self , event ) <EOL> def addChangeListener ( self , listener ) : <EOL> self . _changeListeners . append ( listener ) <EOL> def removeChangeListener ( self , listener ) : <EOL> self . _changeListeners . remove ( listener ) <EOL> def onChange ( self , sender ) : <EOL> pass </s>
