public static void SetControlTabNavigation(DependencyObject element, KeyboardNavigationMode mode) { NoesisGUI_PINVOKE.KeyboardNavigation_SetControlTabNavigation(DependencyObject.getCPtr(element), (int)mode); if (NoesisGUI_PINVOKE.SWIGPendingException.Pending) { throw NoesisGUI_PINVOKE.SWIGPendingException.Retrieve(); } }
private void KeyboardNavigationInnerScopeTest(KeyboardNavigationMode innerScopeMode, Orientation orientation, int[] childrenTabIndex, FocusNavigationDirection direction, int[] expectedTargetChildrenIndex) { Control[] children = new[] { new Control { Name = "child0", Width = 100, Height = 100 }, new Control { Name = "child1", Width = 100, Height = 100 }, new Control { Name = "child2", Width = 100, Height = 100 }, new Control { Name = "child3", Width = 100, Height = 100 }, new Control { Name = "child4", Width = 100, Height = 100 }, }; if (childrenTabIndex != null) { for (int i = 0; i < childrenTabIndex.Length; i++) { KeyboardNavigation.SetTabIndex(children[i], childrenTabIndex[i]); } } StackPanel panel = new StackPanel { Name = "panel", Orientation = orientation }; panel.Children.Add(children[1]); panel.Children.Add(children[2]); panel.Children.Add(children[3]); StackPanel root = new StackPanel { Name = "root", Orientation = orientation, IsRootElement = true }; root.Children.Add(children[0]); root.Children.Add(panel); root.Children.Add(children[4]); KeyboardNavigation.SetTabNavigation(root, KeyboardNavigationMode.Cycle); KeyboardNavigation.SetTabNavigation(panel, innerScopeMode); for (int i = 0; i < expectedTargetChildrenIndex.Length; i++) { Visual currentChild = children[i]; Visual expectedTargetChild = children[expectedTargetChildrenIndex[i]]; Visual targetChild = KeyboardNavigationTarget.FindTarget(currentChild, direction, KeyboardNavigation.TabNavigationProperty); Assert.AreEqual(expectedTargetChild, targetChild); } }
internal void SetTabNavigation(KeyboardNavigationMode mode) { if (!Enum.IsDefined(typeof(KeyboardNavigationMode), mode)) { throw new ArgumentOutOfRangeException(nameof(mode)); } _keyboardNavigationMode = mode; }
public static KeyboardNavigationMode GetDirectionalNavigation(DependencyObject element) { KeyboardNavigationMode ret = (KeyboardNavigationMode)NoesisGUI_PINVOKE.KeyboardNavigation_GetDirectionalNavigation(DependencyObject.getCPtr(element)); if (NoesisGUI_PINVOKE.SWIGPendingException.Pending) { throw NoesisGUI_PINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public static void SetTabNavigation(DependencyObject element, KeyboardNavigationMode mode) { NoesisGUI_PINVOKE.KeyboardNavigation_SetTabNavigation(DependencyObject.getCPtr(element), (int)mode); #if UNITY_EDITOR || NOESIS_API if (NoesisGUI_PINVOKE.SWIGPendingException.Pending) { throw NoesisGUI_PINVOKE.SWIGPendingException.Retrieve(); } #endif }
public static void SetControlTabNavigation(DependencyObject element, KeyboardNavigationMode mode) { if (element == null) { throw new ArgumentNullException("element"); } { NoesisGUI_PINVOKE.KeyboardNavigation_SetControlTabNavigation(DependencyObject.getCPtr(element), (int)mode); } }
public static KeyboardNavigationMode GetDirectionalNavigation(DependencyObject element) { if (element == null) { throw new ArgumentNullException("element"); } { KeyboardNavigationMode ret = (KeyboardNavigationMode)NoesisGUI_PINVOKE.KeyboardNavigation_GetDirectionalNavigation(DependencyObject.getCPtr(element)); return(ret); } }
public static KeyboardNavigationMode GetControlTabNavigation(DependencyObject element) { KeyboardNavigationMode ret = (KeyboardNavigationMode)NoesisGUI_PINVOKE.KeyboardNavigation_GetControlTabNavigation(DependencyObject.getCPtr(element)); #if UNITY_EDITOR || NOESIS_API if (NoesisGUI_PINVOKE.SWIGPendingException.Pending) { throw NoesisGUI_PINVOKE.SWIGPendingException.Retrieve(); } #endif return(ret); }
private void DataGrid_Loaded(object sender, RoutedEventArgs e) { ControlTemplate template1 = this.DataGrid.Template; object obj1; if (template1 == null) { obj1 = (object)null; } else { string name = "DG_ScrollViewer"; DataGrid dataGrid = this.DataGrid; obj1 = template1.FindName(name, (FrameworkElement)dataGrid); } ScrollViewer scrollViewer1 = obj1 as ScrollViewer; object obj2; if (scrollViewer1 == null) { obj2 = (object)null; } else { ControlTemplate template2 = scrollViewer1.Template; if (template2 == null) { obj2 = (object)null; } else { string name = "PART_ColumnHeadersPresenter"; ScrollViewer scrollViewer2 = scrollViewer1; obj2 = template2.FindName(name, (FrameworkElement)scrollViewer2); } } FrameworkElement frameworkElement = (FrameworkElement)obj2; if (frameworkElement == null) { return; } DependencyProperty dp = KeyboardNavigation.TabNavigationProperty; // ISSUE: variable of a boxed type KeyboardNavigationMode local = KeyboardNavigationMode.None; frameworkElement.SetValue(dp, (object)local); }
private static INavigation GetNavigation(Visual scope, DependencyProperty navigationModeProperty) { KeyboardNavigationMode scopeNavigationMode = (KeyboardNavigationMode)scope.GetValue(navigationModeProperty); switch (scopeNavigationMode) { case KeyboardNavigationMode.Continue: return(ContinueNavigation.Default); case KeyboardNavigationMode.Once: return(OnceNavigation.Default); case KeyboardNavigationMode.Cycle: return(CycleNavigation.Default); case KeyboardNavigationMode.None: return(NoneNavigation.Default); case KeyboardNavigationMode.Contained: return(ContainedNavigation.Default); case KeyboardNavigationMode.Local: return(LocalNavigation.Default); } throw new Granular.Exception("Unexpected KeyboardNavigationMode \"{0}\"", scopeNavigationMode); }
protected virtual void HandlePreviewTabKey(KeyEventArgs e) { if (e.Handled) { return; } DataGridContext dataGridContext = DataGridControl.GetDataGridContext(this); if (dataGridContext == null) { return; } DataGridContext currentDataGridContext = dataGridContext.DataGridControl.CurrentContext; if (currentDataGridContext == null) { return; } DependencyObject container = currentDataGridContext.GetContainerFromItem(currentDataGridContext.InternalCurrentItem); if (container != null) { KeyboardNavigationMode tabbingMode = KeyboardNavigation.GetTabNavigation(container); if (tabbingMode != KeyboardNavigationMode.None) { if ((Keyboard.Modifiers == ModifierKeys.None) || (Keyboard.Modifiers == ModifierKeys.Shift)) { DataGridItemsHost.BringIntoViewKeyboardFocusedElement(); //Force the "inline" relayout of the panel //This has no effect if the panel do not have to be updated. this.UpdateLayout(); } } } }
private DependencyObject GetPrevTabWithPrevIndex(DependencyObject e, DependencyObject container, KeyboardNavigationMode tabbingType) { // Find the next max index in the tree // max (index<currentTabIndex) DependencyObject lastTabElement = null; DependencyObject nextTabElement = null; int elementTabPriority = GetTabIndexHelper(e); int maxIndexFirstTab = Int32.MaxValue; int maxIndex = Int32.MaxValue; DependencyObject currElement = GetLastInTree(container); while (currElement != null) { if (IsTabStopOrGroup(currElement) && currElement != container) { int currPriority = GetTabIndexHelper(currElement); if (currPriority < elementTabPriority) { if (currPriority > maxIndex || nextTabElement == null) { maxIndex = currPriority; nextTabElement = currElement; } } if (currPriority > maxIndexFirstTab || lastTabElement == null) { maxIndexFirstTab = currPriority; lastTabElement = currElement; } } currElement = GetPreviousInTree(currElement, container); } // Cycle groups: if not found - return first element if (tabbingType == KeyboardNavigationMode.Cycle && nextTabElement == null) nextTabElement = lastTabElement; return nextTabElement; }
/// <summary> /// Sets the <see cref="TabNavigationProperty"/> for a container. /// </summary> /// <param name="element">The container.</param> /// <param name="value">The <see cref="KeyboardNavigationMode"/> for the container.</param> public static void SetTabNavigation(InputElement element, KeyboardNavigationMode value) { element.SetValue(TabNavigationProperty, value); }
private static IInputElement?GetNextTabInGroup(IInputElement?e, IInputElement container, KeyboardNavigationMode tabbingType) { // None groups: Tab navigation is not supported if (tabbingType == KeyboardNavigationMode.None) { return(null); } // e == null or e == container -> return the first TabStopOrGroup if (e == null || e == container) { return(GetFirstTabInGroup(container)); } if (tabbingType == KeyboardNavigationMode.Once) { return(null); } var nextTabElement = GetNextTabWithSameIndex(e, container); if (nextTabElement != null) { return(nextTabElement); } return(GetNextTabWithNextIndex(e, container, tabbingType)); }
internal bool ValidateTabKeyHandleIsWithin(FrameworkElement originalSource, KeyboardDevice keyboardDevice) { DependencyObject predictedNextVisual = null; //If the original source is not a control (e.g. the cells panel instead of a cell), columns will be used to move focus. //In the case of a ListBox set with Cycle or Contained navigation mode, we must move in the other direction if on the first or last item, //since PedictFocus will throw is we use FocusNavigationDirection.First/Last. if (originalSource != null) { if ((keyboardDevice.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift) { predictedNextVisual = originalSource.PredictFocus(FocusNavigationDirection.Left); if (predictedNextVisual == null) { predictedNextVisual = originalSource.PredictFocus(FocusNavigationDirection.Up); if (predictedNextVisual == null) { KeyboardNavigationMode navigationMode = ( KeyboardNavigationMode )originalSource.GetValue(KeyboardNavigation.TabNavigationProperty); if (navigationMode == KeyboardNavigationMode.Cycle || navigationMode == KeyboardNavigationMode.Contained) { predictedNextVisual = originalSource.PredictFocus(FocusNavigationDirection.Right); if (predictedNextVisual == null) { predictedNextVisual = originalSource.PredictFocus(FocusNavigationDirection.Down); } } } } } else { predictedNextVisual = originalSource.PredictFocus(FocusNavigationDirection.Right); if (predictedNextVisual == null) { predictedNextVisual = originalSource.PredictFocus(FocusNavigationDirection.Down); if (predictedNextVisual == null) { KeyboardNavigationMode navigationMode = ( KeyboardNavigationMode )originalSource.GetValue(KeyboardNavigation.TabNavigationProperty); if (navigationMode == KeyboardNavigationMode.Cycle || navigationMode == KeyboardNavigationMode.Contained) { predictedNextVisual = originalSource.PredictFocus(FocusNavigationDirection.Left); if (predictedNextVisual == null) { predictedNextVisual = originalSource.PredictFocus(FocusNavigationDirection.Up); } } } } } } if (predictedNextVisual != null) { Cell ownerCell = Cell.FindFromChild(predictedNextVisual); if ((ownerCell != null) && (ownerCell.ParentColumn == this.ParentDataGridControl.CurrentColumn)) { if (object.Equals(ownerCell.ParentRow.DataContext, this.ParentDataGridControl.CurrentItemInEdition)) { return(true); } } } return(false); }
/// <summary> /// Sets the <see cref="KeyboardNavigationMode"/> value which is used when navigating through the specified /// element using a directional key. /// </summary> /// <param name="element">The element to update.</param> /// <param name="value">The value to set.</param> public static void SetDirectionalNavigation(DependencyObject element, KeyboardNavigationMode value) { Contract.Require(element, nameof(element)); element.SetValue(DirectionalNavigationProperty, value); }
private static IInputElement?GetPrevTabInGroup(IInputElement?e, IInputElement container, KeyboardNavigationMode tabbingType) { // None groups: Tab navigation is not supported if (tabbingType == KeyboardNavigationMode.None) { return(null); } // Search the last index inside the group if (e == null) { return(GetLastTabInGroup(container)); } if (tabbingType == KeyboardNavigationMode.Once) { return(null); } if (e == container) { return(null); } var nextTabElement = GetPrevTabWithSameIndex(e, container); if (nextTabElement != null) { return(nextTabElement); } return(GetPrevTabWithPrevIndex(e, container, tabbingType)); }
public static KeyboardNavigationMode Unbox_KeyboardNavigationMode(IntPtr val) { KeyboardNavigationMode ret = (KeyboardNavigationMode)NoesisGUI_PINVOKE.Unbox_KeyboardNavigationMode(val); return(ret); }
public static void SetControlTabNavigation(DependencyObject obj, KeyboardNavigationMode value) { obj.SetValue(ControlTabNavigationProperty, value); }
private static bool IsNavigationScope(KeyboardNavigationMode keyboardNavigationMode) { return(keyboardNavigationMode == KeyboardNavigationMode.Once); }
/// <summary> /// Searches the visual subtree contained by <paramref name="navContainer"/> for the previous element in the tab order before <paramref name="navElement"/> /// which has a lower tab index. /// </summary> /// <param name="navContainer">The navigation container that contains <paramref name="navElement"/>.</param> /// <param name="navElement">The element at which to begin the search.</param> /// <param name="navProp">The navigation property to evaluate.</param> /// <param name="navMode">The currently active navigation mode.</param> /// <returns>The previous element in the tab order before <paramref name="navElement"/> which has a lower tab index, or <c>null</c>.</returns> private static DependencyObject FindPrevVisualElementWithLowerTabIndex(DependencyObject navContainer, DependencyObject navElement, DependencyProperty navProp, KeyboardNavigationMode navMode) { var targetTabIndex = KeyboardNavigation.GetTabIndex(navElement); var maxIndex = Int32.MinValue; var maxElement = default(DependencyObject); var lastIndex = Int32.MinValue; var lastElement = default(DependencyObject); var current = FindLastVisualElementInTree(navContainer, navProp); while (true) { if (IsNavigationStop(current) || IsNavigationContainer(current, navProp)) { var currentTabIndex = KeyboardNavigation.GetTabIndex(current); if (currentTabIndex < targetTabIndex && (maxElement == null || currentTabIndex > maxIndex)) { maxIndex = currentTabIndex; maxElement = current; } if (lastElement == null || currentTabIndex > lastIndex) { lastIndex = currentTabIndex; lastElement = current; } } current = TraverseVisualTreePrev(navContainer, current, navProp); if (current == null) break; } return (maxElement == null && navMode == KeyboardNavigationMode.Cycle) ? lastElement : maxElement; }
/// <summary> /// Searches the visual subtree contained by <paramref name="navContainer"/> for the previous element in the tab order before <paramref name="navElement"/>. /// </summary> /// <param name="navContainer">The navigation container that contains <paramref name="navElement"/>.</param> /// <param name="navElement">The element at which to begin the search.</param> /// <param name="navProp">The navigation property to evaluate.</param> /// <param name="navMode">The currently active navigation mode.</param> /// <returns>The previous element in the tab order before <paramref name="navElement"/>, or <c>null</c>.</returns> private static DependencyObject FindPrevVisualElementWithinContainer(DependencyObject navContainer, DependencyObject navElement, DependencyProperty navProp, KeyboardNavigationMode navMode) { if (navMode == KeyboardNavigationMode.None) return null; if (navElement == null) return GetLastNavigationStop(navContainer, navProp); if (navMode == KeyboardNavigationMode.Once || navElement == navContainer) return null; return FindPrevVisualElementWithSameTabIndex(navContainer, navElement, navProp) ?? FindPrevVisualElementWithLowerTabIndex(navContainer, navElement, navProp, navMode); }
/// <summary> /// Searches the visual subtree contained by <paramref name="navContainer"/> for the next element in the tab order after <paramref name="navElement"/> /// which has a higher tab index. /// </summary> /// <param name="navContainer">The navigation container that contains <paramref name="navElement"/>.</param> /// <param name="navElement">The element at which to begin the search.</param> /// <param name="navProp">The navigation property to evaluate.</param> /// <param name="navMode">The currently active navigation mode.</param> /// <returns>The next element in the tab order after <paramref name="navElement"/> which has a higher tab index, or <c>null</c>.</returns> private static DependencyObject FindNextVisualElementWithHigherTabIndex(DependencyObject navContainer, DependencyObject navElement, DependencyProperty navProp, KeyboardNavigationMode navMode) { var targetTabIndex = KeyboardNavigation.GetTabIndex(navElement); var minIndex = Int32.MaxValue; var minElement = default(DependencyObject); var firstIndex = Int32.MaxValue; var firstElement = default(DependencyObject); var current = navContainer; while (true) { current = TraverseVisualTreeNext(navContainer, current, navProp); if (current == null) break; if (IsNavigationStop(current) || IsNavigationContainer(current, navProp)) { var currentTabIndex = KeyboardNavigation.GetTabIndex(current); if (currentTabIndex > targetTabIndex && (minElement == null || currentTabIndex < minIndex)) { minIndex = currentTabIndex; minElement = current; } if (firstElement == null || currentTabIndex < firstIndex) { firstIndex = currentTabIndex; firstElement = current; } } } return (minElement == null && navMode == KeyboardNavigationMode.Cycle) ? firstElement : minElement; }
/// <summary> /// Searches the visual subtree contained by <paramref name="navContainer"/> for the next element in the tab order after <paramref name="navElement"/>. /// </summary> /// <param name="navContainer">The navigation container that contains <paramref name="navElement"/>.</param> /// <param name="navElement">The element at which to begin the search.</param> /// <param name="navProp">The navigation property to evaluate.</param> /// <param name="navMode">The currently active navigation mode.</param> /// <returns>The next element in the tab order after <paramref name="navElement"/>, or <c>null</c>.</returns> private static DependencyObject FindNextVisualElementWithinContainer(DependencyObject navContainer, DependencyObject navElement, DependencyProperty navProp, KeyboardNavigationMode navMode) { if (navMode == KeyboardNavigationMode.None) return null; if ((navElement ?? navContainer) == navContainer) return GetFirstNavigationStop(navContainer, navProp); if (navMode == KeyboardNavigationMode.Once) return null; return FindNextVisualElementWithSameTabIndex(navContainer, navElement, navProp) ?? FindNextVisualElementWithHigherTabIndex(navContainer, navElement, navProp, navMode); }
private DependencyObject GetPrevTabInGroup(DependencyObject e, DependencyObject container, KeyboardNavigationMode tabbingType) { // None groups: Tab navigation is not supported if (tabbingType == KeyboardNavigationMode.None) return null; // Search the last index inside the group if (e==null) { return GetLastTabInGroup(container); } if (tabbingType == KeyboardNavigationMode.Once) return null; if (e == container) return null; DependencyObject nextTabElement = GetPrevTabWithSameIndex(e, container); if (nextTabElement != null) return nextTabElement; return GetPrevTabWithPrevIndex(e, container, tabbingType); }
/// <summary> /// Writes the attached property DirectionalNavigation to the given element. /// </summary> /// <param name="element">The element to which to write the attached property.</param> /// <param name="mode">The property value to set</param> /// <seealso cref="KeyboardNavigation.DirectionalNavigationProperty" /> public static void SetDirectionalNavigation(DependencyObject element, KeyboardNavigationMode mode) { if (element == null) { throw new ArgumentNullException("element"); } element.SetValue(DirectionalNavigationProperty, mode); }
public static void SetDirectionalNavigation(DependencyObject obj, KeyboardNavigationMode value) { obj.SetValue(DirectionalNavigationProperty, value); }
public static IntPtr Box_KeyboardNavigationMode(KeyboardNavigationMode val) { IntPtr ret = NoesisGUI_PINVOKE.Box_KeyboardNavigationMode((int)val); return(ret); }
public static void SetTabNavigation(System.Windows.DependencyObject element, KeyboardNavigationMode mode) { }
private static void SetPreviousDirectionalNavigationMode( DependencyObject d, KeyboardNavigationMode value ) { d.SetValue( TableflowViewItemsHost.PreviousDirectionalNavigationModeProperty, value ); }
private static IInputElement?GetPrevTabWithPrevIndex(IInputElement e, IInputElement container, KeyboardNavigationMode tabbingType) { // Find the next max index in the tree // max (index<currentTabIndex) IInputElement?lastTabElement = null; IInputElement?nextTabElement = null; int elementTabPriority = KeyboardNavigation.GetTabIndex(e); int maxIndexFirstTab = Int32.MaxValue; int maxIndex = Int32.MaxValue; var currElement = GetLastInTree(container); while (currElement != null) { if (IsTabStopOrGroup(currElement) && currElement != container) { int currPriority = KeyboardNavigation.GetTabIndex(currElement); if (currPriority < elementTabPriority) { if (currPriority > maxIndex || nextTabElement == null) { maxIndex = currPriority; nextTabElement = currElement; } } if (currPriority > maxIndexFirstTab || lastTabElement == null) { maxIndexFirstTab = currPriority; lastTabElement = currElement; } } currElement = GetPreviousInTree(currElement, container); } // Cycle groups: if not found - return first element if (tabbingType == KeyboardNavigationMode.Cycle && nextTabElement == null) { nextTabElement = lastTabElement; } return(nextTabElement); }
private static bool IsNavigationScope(KeyboardNavigationMode keyboardNavigationMode) { return keyboardNavigationMode == KeyboardNavigationMode.Once; }
public static IInputElement?GetPrevTab(IInputElement?e, IInputElement?container, bool goDownOnly) { if (e is null && container is null) { throw new InvalidOperationException("Either 'e' or 'container' must be non-null."); } if (container is null) { container = GetGroupParent(e !); } KeyboardNavigationMode tabbingType = GetKeyNavigationMode(container); if (e == null) { // Using ActiveElement if set var activeElement = GetActiveElement(container); if (activeElement != null) { return(GetPrevTab(null, activeElement, true)); } else { // If we Shift+Tab on a container with KeyboardNavigationMode=Once, and ActiveElement is null // then we want to go to the first item (not last) within the container if (tabbingType == KeyboardNavigationMode.Once) { var firstTabElement = GetNextTabInGroup(null, container, tabbingType); if (firstTabElement == null) { if (IsTabStop(container)) { return(container); } if (goDownOnly) { return(null); } return(GetPrevTab(container, null, false)); } else { return(GetPrevTab(null, firstTabElement, true)); } } } } else { if (tabbingType == KeyboardNavigationMode.Once || tabbingType == KeyboardNavigationMode.None) { if (goDownOnly || container == e) { return(null); } // FocusedElement should not be e otherwise we will delegate focus to the same element if (IsTabStop(container)) { return(container); } return(GetPrevTab(container, null, false)); } } // All groups (except Once) - continue IInputElement?loopStartElement = null; IInputElement?nextTabElement = e; // Look for element with the same TabIndex before the current element while ((nextTabElement = GetPrevTabInGroup(nextTabElement, container, tabbingType)) != null) { if (nextTabElement == container && tabbingType == KeyboardNavigationMode.Local) { break; } // At this point nextTabElement is TabStop or TabGroup // In case it is a TabStop only return the element if (IsTabStop(nextTabElement) && !IsGroup(nextTabElement)) { return(nextTabElement); } // Avoid the endless loop here if (loopStartElement == nextTabElement) { break; } if (loopStartElement == null) { loopStartElement = nextTabElement; } // At this point nextTabElement is TabGroup var lastTabElementInside = GetPrevTab(null, nextTabElement, true); if (lastTabElementInside != null) { return(lastTabElementInside); } } if (tabbingType == KeyboardNavigationMode.Contained) { return(null); } if (e != container && IsTabStop(container)) { return(container); } // If end of the subtree is reached or there no other elements above if (!goDownOnly && GetParent(container) != null) { return(GetPrevTab(container, null, false)); } return(null); }
private static IInputElement?GetNextTabWithNextIndex(IInputElement e, IInputElement container, KeyboardNavigationMode tabbingType) { // Find the next min index in the tree // min (index>currentTabIndex) IInputElement?nextTabElement = null; IInputElement?firstTabElement = null; int minIndexFirstTab = int.MinValue; int minIndex = int.MinValue; int elementTabPriority = KeyboardNavigation.GetTabIndex(e); IInputElement?currElement = container; while ((currElement = GetNextInTree(currElement, container)) != null) { if (IsTabStopOrGroup(currElement)) { int currPriority = KeyboardNavigation.GetTabIndex(currElement); if (currPriority > elementTabPriority) { if (currPriority < minIndex || nextTabElement == null) { minIndex = currPriority; nextTabElement = currElement; } } if (currPriority < minIndexFirstTab || firstTabElement == null) { minIndexFirstTab = currPriority; firstTabElement = currElement; } } } // Cycle groups: if not found - return first element if (tabbingType == KeyboardNavigationMode.Cycle && nextTabElement == null) { nextTabElement = firstTabElement; } return(nextTabElement); }
private DependencyObject GetNextTabInGroup(DependencyObject e, DependencyObject container, KeyboardNavigationMode tabbingType) { // None groups: Tab navigation is not supported if (tabbingType == KeyboardNavigationMode.None) return null; // e == null or e == container -> return the first TabStopOrGroup if (e == null || e == container) { return GetFirstTabInGroup(container); } if (tabbingType == KeyboardNavigationMode.Once) return null; DependencyObject nextTabElement = GetNextTabWithSameIndex(e, container); if (nextTabElement != null) return nextTabElement; return GetNextTabWithNextIndex(e, container, tabbingType); }
/// <summary> /// Sets the <see cref="KeyboardNavigationMode"/> value which is used when navigating through the specified /// element using a directional key. /// </summary> /// <param name="element">The element to update.</param> /// <param name="value">The value to set.</param> public static void SetDirectionalNavigation(DependencyObject element, KeyboardNavigationMode value) { Contract.Require(element, "element"); element.SetValue(DirectionalNavigationProperty, value); }
private void KeyboardNavigationInnerScopeTest(KeyboardNavigationMode innerScopeMode, Orientation orientation, int[] childrenTabIndex, FocusNavigationDirection direction, int[] expectedTargetChildrenIndex) { Control[] children = new[] { new Control { Name = "child0", Width = 100, Height = 100 }, new Control { Name = "child1", Width = 100, Height = 100 }, new Control { Name = "child2", Width = 100, Height = 100 }, new Control { Name = "child3", Width = 100, Height = 100 }, new Control { Name = "child4", Width = 100, Height = 100 }, }; if (childrenTabIndex != null) { for (int i = 0; i < childrenTabIndex.Length; i++) { KeyboardNavigation.SetTabIndex(children[i], childrenTabIndex[i]); } } StackPanel panel = new StackPanel { Name = "panel", Orientation = orientation}; panel.Children.Add(children[1]); panel.Children.Add(children[2]); panel.Children.Add(children[3]); StackPanel root = new StackPanel { Name = "root", Orientation = orientation, IsRootElement = true }; root.Children.Add(children[0]); root.Children.Add(panel); root.Children.Add(children[4]); KeyboardNavigation.SetTabNavigation(root, KeyboardNavigationMode.Cycle); KeyboardNavigation.SetTabNavigation(panel, innerScopeMode); for (int i = 0; i < expectedTargetChildrenIndex.Length; i++) { Visual currentChild = children[i]; Visual expectedTargetChild = children[expectedTargetChildrenIndex[i]]; Visual targetChild = KeyboardNavigationTarget.FindTarget(currentChild, direction, KeyboardNavigation.TabNavigationProperty); Assert.AreEqual(expectedTargetChild, targetChild); } }
public static void SetControlTabNavigation(DependencyObject obj, KeyboardNavigationMode value) { obj.SetValue(ControlTabNavigationProperty, value); }
public static void SetDirectionalNavigation(DependencyObject obj, KeyboardNavigationMode value) { obj.SetValue(DirectionalNavigationProperty, value); }
public static KeyboardNavigationMode GetDirectionalNavigation(DependencyObject element) { KeyboardNavigationMode ret = (KeyboardNavigationMode)NoesisGUI_PINVOKE.KeyboardNavigation_GetDirectionalNavigation(DependencyObject.getCPtr(element)); return(ret); }
/// <summary> /// Sets the <see cref="KeyboardNavigationMode"/> value which is used when navigating through the specified /// element using the Tab key. /// </summary> /// <param name="element">The element to update.</param> /// <param name="value">The value to set.</param> public static void SetTabNavigation(DependencyObject element, KeyboardNavigationMode value) { Contract.Require(element, nameof(element)); element.SetValue(TabNavigationProperty, value); }
/// <summary> /// Sets the <see cref="TabNavigationProperty"/> for a container. /// </summary> /// <param name="element">The container.</param> /// <param name="value">The <see cref="KeyboardNavigationMode"/> for the container.</param> public static void SetTabNavigation(InputElement element, KeyboardNavigationMode value) { element.SetValue(TabNavigationProperty, value); }
public static void SetDirectionalNavigation(DependencyObject element, KeyboardNavigationMode mode) { NoesisGUI_PINVOKE.KeyboardNavigation_SetDirectionalNavigation(DependencyObject.getCPtr(element), (int)mode); }
// Find the element with the next TabIndex after the current element private DependencyObject GetNextTabWithNextIndex(DependencyObject e, DependencyObject container, KeyboardNavigationMode tabbingType) { // Find the next min index in the tree // min (index>currentTabIndex) DependencyObject nextTabElement = null; DependencyObject firstTabElement = null; int minIndexFirstTab = Int32.MinValue; int minIndex = Int32.MinValue; int elementTabPriority = GetTabIndexHelper(e); DependencyObject currElement = container; while ((currElement = GetNextInTree(currElement, container)) != null) { if (IsTabStopOrGroup(currElement)) { int currPriority = GetTabIndexHelper(currElement); if (currPriority > elementTabPriority) { if (currPriority < minIndex || nextTabElement == null) { minIndex = currPriority; nextTabElement = currElement; } } if (currPriority < minIndexFirstTab || firstTabElement == null) { minIndexFirstTab = currPriority; firstTabElement = currElement; } } } // Cycle groups: if not found - return first element if (tabbingType == KeyboardNavigationMode.Cycle && nextTabElement == null) nextTabElement = firstTabElement; return nextTabElement; }
public static void SetTabNavigation(System.Windows.DependencyObject element, KeyboardNavigationMode mode) { }