def handle_events(self):
        """Iterate over event queue processing events."""
        for event in SERVICES_NS.get_events():

            ### raise special exception if user attempts
            ### to quit the application
            if event.type == QUIT:
                raise QuitAppException

            ### lose focus if escape key is released

            elif event.type == KEYUP:

                if event.key == K_ESCAPE:
                    self.lose_focus()

                elif event.key in (K_RETURN, K_KP_ENTER):
                    self.choose_option_under_mouse()

            ### act when the mouse left or right button
            ### is released

            elif event.type == MOUSEBUTTONUP:

                if event.button in (1, 3):

                    ## if mouse is out of the body, lose
                    ## focus, regardless of the button
                    ## released

                    if self.out_of_body(event.pos):
                        self.lose_focus()

                    ## otherwise, if the button released
                    ## is the left button, trigger the
                    ## mouse release method

                    elif event.button == 1:
                        self.on_mouse_release(event)

                elif event.button in (4, 5):
                    self.on_mousewheel(event)

            ### if the mouse moves try highlighting the
            ### hovered option, if there's one

            elif event.type == MOUSEMOTION:
                self.on_mouse_motion(event.pos)

            ### if window is resized, set handle_input
            ### to a new callable that keeps handling
            ### events and mouse pos and at the same time
            ### watches out for movement of the widget

            elif event.type == WINDOW_RESIZE_EVENT_TYPE:
                self.handle_input = self.watch_out_for_movement
Iterate over event queue processing events.
nodezator/widget/optionmenu/op.py