comparison mamba/widgets/base.py @ 283:11cf3a259eaa

Iterate over copies, to avoid some issues with children changing in the loop
author Neil Muller <drnlmuller@gmail.com>
date Thu, 15 Sep 2011 21:44:26 +0200
parents 190aa1481908
children a0c60e0c1ef2
comparison
equal deleted inserted replaced
282:56cd71696dff 283:11cf3a259eaa
106 def event(self, ev): 106 def event(self, ev):
107 """Push an event down through the tree, and fire our own event as a 107 """Push an event down through the tree, and fire our own event as a
108 last resort 108 last resort
109 """ 109 """
110 if ev.type in (MOUSEMOTION, MOUSEBUTTONUP, MOUSEBUTTONDOWN): 110 if ev.type in (MOUSEMOTION, MOUSEBUTTONUP, MOUSEBUTTONDOWN):
111 for child in self.children: 111 for child in self.children[:]:
112 if child.rect.collidepoint(ev.pos): 112 if child.rect.collidepoint(ev.pos):
113 if ev.type == MOUSEBUTTONDOWN and child.focussable: 113 if ev.type == MOUSEBUTTONDOWN and child.focussable:
114 child.grab_focus() 114 child.grab_focus()
115 if child.event(ev): 115 if child.event(ev):
116 return True 116 return True
120 if child.focussed or i == self.focussed_child: 120 if child.focussed or i == self.focussed_child:
121 if child.event(ev): 121 if child.event(ev):
122 return True 122 return True
123 else: 123 else:
124 # Other events go to all children first 124 # Other events go to all children first
125 for child in self.children: 125 for child in self.children[:]:
126 if child.event(ev): 126 if child.event(ev):
127 return True 127 return True
128 if super(Container, self).event(ev): 128 if super(Container, self).event(ev):
129 return True 129 return True
130 if (self.parent is None and ev.type == KEYDOWN 130 if (self.parent is None and ev.type == KEYDOWN