/// <summary>Moves the focus to the next element as defined by tabindex. /// All elements with an explicit tabindex are defined as being before all /// elements which don't have an explicit tabindex.</summary> /// <returns>True if anything happened.</returns> public bool TabNext() { // - From the current focused element, we check all elements after it to see which // has the 'closest' tabIndex to currentIndex. // - If there are no immediate matches, we wrap around the DOM and continue searching // - If there is no current focused element, we start at very top and don't wrap at all. // These track the current best found element. int bestSoFar = int.MaxValue; HtmlElement best = null; // Get the current focused element: HtmlElement focused = htmlActiveElement; if (focused == null) { // Haven't got one - hunt for a node with a tabindex first: body.SearchChildFocusable(null, true, 0, ref bestSoFar, ref best); if (best == null) { // Find the first focusable node: body.SearchChildFocusable(null, true, -1, ref bestSoFar, ref best); } } else { best = focused.GetFocusedNext(); } if (best != null) { // Focus it now: best.focus(); return(true); } return(false); }