def focusNextElement(self, direction=1):
        '''Move the focus on to the next element.
        '''
        if not self._focus_order: return

        # determine the index of the next element to possibly focus on
        N = len(self._focus_order)
        if self.focused_element is None:
            if direction == 1: i = 0
            else: i = 1-N
        else:
            try:
                i = self._focus_order.index(self.focused_element.id) + direction
            except ValueError:
                # element not in the focus order list
                i = 0
            if i < 0: i = N-1
            if i >= N: i = 0

        # now start at that index and work through the focusable elements
        # until we find a visible & enabled one to focus on
        j = i
        while True:
            element = self._by_id[self._focus_order[i]]
            if element.isEnabled() and element.isVisible():
                self.setFocus(element, source='tab')
                return
            i += direction
            if i < 0: i = N-1
            if i >= N: i = 0
            if i == j: return       # no focusable element found


    # NOW THE EVENT HANDLERS
dataset/ETHPy150Open ardekantur/pyglet/contrib/wydget/wydget/event.py/GUIEventDispatcher.focusNextElement/swapped operands of `-`