/// <summary> /// Dispatches key /// </summary> private bool ProcessKey(Element container, string keyname) { Debug.Assert(!String.IsNullOrEmpty(keyname), "keyname cannot be null"); var selector = String.Format("[accesskey=='{0}'],[accesskey-alt=='{0}']", keyname); var element = container.Find(selector, e => e.IsVisible && e.IsEnabled); if (element != null) { if (element.CallBehaviorMethod(BehaviorMethods.DoClick)) return true; var parent = element.Parent; parent.SendEvent(BehaviorEventType.ActivateChild, element); } return false; }
/// <summary> /// Set current item /// </summary> protected virtual void SetCurrentItem(Element ctl, Element item) { // previously selected item var prev_current = ctl.Find(":root > :current"); var prev = ctl.Find(":root > :expanded"); if (prev_current != null && prev_current != item) prev_current.SetState(ElementState.None, ElementState.Current); if (prev != null) { if (prev == item) return; prev.SetState(ElementState.None, ElementState.Current | ElementState.Expanded); } item.SetState(ElementState.Current | ElementState.Expanded); item.ScrollToView(); }