@@ -173,7 +173,7 @@ def draw(self):
173173class  Text (Shape ):
174174    """Draw a line of text on the screen.""" 
175175    fontcolor  =  BLACK 
176-     fontsize  =  24 
176+     fontsize  =  48 
177177    fontname  =  None 
178178    bgcolor  =  None 
179179
@@ -267,7 +267,7 @@ def __init__(self, msg, cmd, size=None, color=None, d=None, **kwargs):
267267            Button .size  =  list (size )
268268        self .size  =  Button .size 
269269        self .rect .size  =  self .size 
270-         Game .pos [1 ] +=  Button .size [1 ]
270+         Shape .pos [1 ] +=  Button .size [1 ]
271271
272272        if  d  !=  None :
273273            Button .d  =  d 
@@ -432,13 +432,7 @@ def run(self):
432432                        self .current_obj .on_key (event )
433433
434434                elif  event .type  ==  MOUSEBUTTONDOWN :
435-                     for  obj  in  Game .objects :
436-                         if  obj .rect .collidepoint (event .pos ):
437-                             if  self .current_obj :
438-                                 self .current_obj .is_active  =  False 
439-                             self .current_obj  =  obj 
440-                             obj .is_active  =  True 
441-                             obj .on_click (event )
435+                     self .select_objects (event )
442436
443437                elif  event .type  ==  MOUSEMOTION :
444438                    if  self .current_obj :
@@ -482,6 +476,18 @@ def find_objects(self, pos):
482476        """Return the objects at position.""" 
483477        return  [obj  for  obj  in  Game .objects  if  obj .rect .collidepoint (pos )]
484478
479+     def  select_objects (self , event ):
480+         """Select objects at position pos.""" 
481+         objs  =  self .find_objects (event .pos )
482+         for  obj  in  objs :
483+             if  self .current_obj :
484+                 self .current_obj .is_active  =  False 
485+             self .current_obj  =  obj 
486+             obj .is_active  =  True 
487+             obj .on_click (event )
488+         if  len (objs ) ==  0 :
489+             self .current_obj .is_active  =  False 
490+ 
485491    def  do_shortcuts (self , event ):
486492        """Check if the key/mod combination is part of the shortcuts 
487493        dictionary and execute it. More shortcuts can be added  
@@ -493,6 +499,8 @@ def do_shortcuts(self, event):
493499            exec (self .shortcuts [k ])
494500        elif  (k , m ) in  self .shortcuts :
495501            exec (self .shortcuts [k , m ])
496-         
502+ 
503+ 
504+ 
497505if  __name__  ==  '__main__' :
498506    Game ().run ()
0 commit comments