def on_mouse_action(self, method_name, event):
        """Check whether mouse action occurred inside widget.

        Parameters
        ==========
        method_name (string)
            either 'on_mouse_click' or 'on_mouse_release',
            actions which we track in this method.
        event (custom instance)
            pygame.event.Event of type
            pygame.MOUSEBUTTONDOWN or MOUSEBUTTONUP;
            check pygame.event module documentation on
            pygame website for more info about these event
            objects.

        If inside the file manager boundaries, determine
        if it was inside one of the panels or buttons,
        triggering the appropriate action. If outside,
        get out of the file manager loop using the
        'cancel' method.
        """
        mouse_pos = event.pos

        ### if mouse was released inside file manager

        if self.rect.collidepoint(mouse_pos):

            ## see if one of the panels collides

            for panel in self.panels:

                if panel.rect.collidepoint(mouse_pos):

                    try:
                        method = getattr(panel, method_name)

                    except AttributeError:
                        pass

                    else:

                        method(event)
                        return

            ## see if buttons were pressed (mouse released)

            for button in self.buttons:

                if button.rect.collidepoint(mouse_pos):

                    try:
                        method = getattr(button, method_name)
                    except AttributeError:
                        pass

                    else:

                        method(event)
                        return

        ### otherwise trigger the exit of the file manager
        ### loop by cancelling
        else:
            self.cancel()
Check whether mouse action occurred inside widget.

        Parameters
        ==========
        method_name (string)
            either 'on_mouse_click' or 'on_mouse_release',
            actions which we track in this method.
        event (custom instance)
            pygame.event.Event of type
            pygame.MOUSEBUTTONDOWN or MOUSEBUTTONUP;
            check pygame.event module documentation on
            pygame website for more info about these event
            objects.

        If inside the file manager boundaries, determine
        if it was inside one of the panels or buttons,
        triggering the appropriate action. If outside,
        get out of the file manager loop using the
        'cancel' method.
        
nodezator/fileman/op.py