original_docstring: 
          Internal event handler. Users should not have to interface with this directly. Instead, use the event listener system or handleEvent() for more control.
          
docstring: Internal event handler. Users should not have to interface with this directly. Instead, use the event listener system or handleEvent() for more control.
docstring_tokens: Internal event handler . Users should not have to interface with this directly . Instead use the event listener system or handleEvent () for more control .
code: async def _handleEvent(self,event):
  
          """
          Internal event handler. Users should not have to interface with this directly. Instead, use the event listener system or handleEvent() for more control.
          """
  
          reverse_subwindows = self.subwindows.copy()
          reverse_subwindows.reverse()
  
          if event.type in (pygame.MOUSEBUTTONDOWN, pygame.MOUSEBUTTONUP, pygame.MOUSEMOTION):
  
              #For mouse events we want the user to interface with the provided convenience methods instead of manually checking positioning and events.
              #This means that the event handler has to check if the mouse event occured within this window. If it did, we should call the respective
              #event handler method for that event. If it returns True, nothing else has to be done (although we will return True as well to signal the other
              #windows that this even has already been handled). If it returns False, we propagate the event to our subwindows with realigned position values
              #to match their position relative to this window. If any of the subwindows event handlers return True for this event we skip the others and return
              #True as well, otherwise we return False.
              #If the event occured outside of this windows boundaries, we call the onMouseLeave method and send a EVENT_MOUSE_LEFT to all subwindows to signal
              #them that the mouse has left this area of the screen.
              #NOTE: onMouseEnter and onMouseLeave should only be called once the mouse_in_frame state changes to prevent code from being executed to often. This
              #means that if our mouse_in_frame state is False and we receive a mouse event that is outside of window boundaries we don't have to dispatch a 
              #EVENT_MOUSE_LEFT event since all subwindows should know about it already. Same for if we receive such an event ourselves.)
  
  
              orgpos = event.pos
              relpos = [orgpos[0]-self.pos[0],orgpos[1]-self.pos[1]] #calculate relative event position
              if self.pointInWindow(orgpos):
                  #Event occured within window boundaries
  
                  if not self.mouse_in_frame:
  
                      #call mouse enter event first in case it needs to set something up
                      await self.onMouseEnter(event)
                      self.mouse_in_frame = True #set new state
  
                  #Generate new event
                  attr = event.dict.copy()
                  attr["pos"] = relpos
                  newevent = makeEvent(event.type, attr)
  
                  #call convenience methods
                  returned = False
  
                  if event.type == pygame.MOUSEBUTTONDOWN:
  
                      returned = await self.onMouseButtonDown(newevent)
  
                  elif event.type == pygame.MOUSEBUTTONUP:
  
                      returned = await self.onMouseButtonUp(newevent)
  
                  elif event.type == pygame.MOUSEMOTION:
  
                      returned = await self.onMouseMotion(newevent)
  
                  if returned:
  
                      #Event handler consumed event, return
                      return True
                  
                  #propagate event
                  for i in reverse_subwindows:
                      if await i.handleEvent(newevent):
                          return True
                  return False #Subwindows did not consume the event, return False
  
              #Event occured outside of window boundaries
  
              await self._handleMouseLeave()
  
          elif event.type == EVENT_MOUSE_LEFT:
  
              await self._handleMouseLeave() #make sure we (and all other subwindows) are aware of the mouse leaving the window
  
          elif event.type == pygame.KEYDOWN:
  
              #Handle keystroke and propagate event
  
              if await self.onKeystroke(event):
                  return True
              for i in reverse_subwindows:
                  if await i.handleEvent(event):
                      return True
              return False
  
          else:
  
              #Propagate event
  
              for i in reverse_subwindows:
                  if await i.handleEvent(event):
                      return True
              return False
code_tokens: async def _handleEvent ( self , event ) : reverse_subwindows = self . subwindows . copy ( ) reverse_subwindows . reverse ( ) if event . type in ( pygame . MOUSEBUTTONDOWN , pygame . MOUSEBUTTONUP , pygame . MOUSEMOTION ) : orgpos = event . pos relpos = [ orgpos [ 0 ] - self . pos [ 0 ] , orgpos [ 1 ] - self . pos [ 1 ] ] if self . pointInWindow ( orgpos ) : if not self . mouse_in_frame : await self . onMouseEnter ( event ) self . mouse_in_frame = True attr = event . dict . copy ( ) attr [ "pos" ] = relpos newevent = makeEvent ( event . type , attr ) returned = False if event . type == pygame . MOUSEBUTTONDOWN : returned = await self . onMouseButtonDown ( newevent ) elif event . type == pygame . MOUSEBUTTONUP : returned = await self . onMouseButtonUp ( newevent ) elif event . type == pygame . MOUSEMOTION : returned = await self . onMouseMotion ( newevent ) if returned : return True for i in reverse_subwindows : if await i . handleEvent ( newevent ) : return True return False await self . _handleMouseLeave ( ) elif event . type == EVENT_MOUSE_LEFT : await self . _handleMouseLeave ( ) elif event . type == pygame . KEYDOWN : if await self . onKeystroke ( event ) : return True for i in reverse_subwindows : if await i . handleEvent ( event ) : return True return False else : for i in reverse_subwindows : if await i . handleEvent ( event ) : return True return False
short_docstring: Internal event handler.
short_docstring_tokens: Internal event handler .
comment: """
          Internal event handler. Users should not have to interface with this directly. Instead, use the event listener system or handleEvent() for more control.
          """$SEP$#For mouse events we want the user to interface with the provided convenience methods instead of manually checking positioning and events.$SEP$#This means that the event handler has to check if the mouse event occured within this window. If it did, we should call the respective$SEP$#event handler method for that event. If it returns True, nothing else has to be done (although we will return True as well to signal the other$SEP$#windows that this even has already been handled). If it returns False, we propagate the event to our subwindows with realigned position values$SEP$#to match their position relative to this window. If any of the subwindows event handlers return True for this event we skip the others and return$SEP$#True as well, otherwise we return False.$SEP$#If the event occured outside of this windows boundaries, we call the onMouseLeave method and send a EVENT_MOUSE_LEFT to all subwindows to signal$SEP$#them that the mouse has left this area of the screen.$SEP$#NOTE: onMouseEnter and onMouseLeave should only be called once the mouse_in_frame state changes to prevent code from being executed to often. This$SEP$#means that if our mouse_in_frame state is False and we receive a mouse event that is outside of window boundaries we don't have to dispatch a $SEP$#EVENT_MOUSE_LEFT event since all subwindows should know about it already. Same for if we receive such an event ourselves.)$SEP$#calculate relative event position$SEP$#Event occured within window boundaries$SEP$#call mouse enter event first in case it needs to set something up$SEP$#set new state$SEP$#Generate new event$SEP$#call convenience methods$SEP$#Event handler consumed event, return$SEP$#propagate event$SEP$#Subwindows did not consume the event, return False$SEP$#Event occured outside of window boundaries$SEP$#make sure we (and all other subwindows) are aware of the mouse leaving the window$SEP$#Handle keystroke and propagate event$SEP$#Propagate event