def handle_input(self):
        """Retrieve data, execute setups and handle events."""
        ### retrieve commonly used data, mouse position,
        ### and store it in a mouse_pos attribute for easy
        ### access by other methods in the class
        self.mouse_pos = SERVICES_NS.get_mouse_pos()

        ### check if there's an arrow hovered and scroll it
        self.manage_scrolling()

        ### check if there's a hovered widget, performing
        ### admin tasks along the way
        self.manage_hovered_widget()

        ### process events from the event queue

        for event in SERVICES_NS.get_events():
            if event.type == QUIT:
                raise QuitAppException

            elif event.type == KEYUP:

                # if released escape key, focus the
                # loop holder

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

                # otherwise, invoke the hovered widget,
                # if any

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

            ## mouse

            elif event.type == MOUSEBUTTONUP:

                # left click
                if event.button == 1:
                    self.invoke_hovered_widget()

                # right click

                elif event.button == 3:

                    # if click was out of any meaningful area
                    # focus the loop holder
                    if self.is_clicking_out():
                        self.focus_loop_holder()

                # mouse wheel

                elif event.button in (4, 5):
                    self.mouse_scroll(event.button)
Retrieve data, execute setups and handle events.
nodezator/menu/behaviour.py