protected override void OnKeyTipAccessed(KeyTipAccessedEventArgs e) { if (e.OriginalSource == this) { if (this.IsEditable) { if (EditableTextBoxSite != null) { RibbonHelper.OpenParentRibbonGroupDropDownSync(this, TemplateApplied); EditableTextBoxSite.Focus(); EditableTextBoxSite.SelectAll(); } e.Handled = true; } else { base.OnKeyTipAccessed(e); } } else { base.OnKeyTipAccessed(e); } }
private void OnKeyTipExactMatch(DependencyObject exactMatchElement) { if (!((bool)(exactMatchElement.GetValue(UIElement.IsEnabledProperty)))) { RibbonHelper.Beep(); return; } HideCurrentShowingKeyTips(); _prefixText = string.Empty; KeyTipAccessedEventArgs eventArgs = new KeyTipAccessedEventArgs(); eventArgs.RoutedEvent = PreviewKeyTipAccessedEvent; object oldFocusedElement = Keyboard.FocusedElement; IInputElement inputElement = exactMatchElement as IInputElement; if (inputElement != null) { inputElement.RaiseEvent(eventArgs); eventArgs.RoutedEvent = KeyTipAccessedEvent; inputElement.RaiseEvent(eventArgs); } // KeyTips might have been dismissed by one of the event handlers // hence check again. if (State != KeyTipState.None) { object newFocusedElement = Keyboard.FocusedElement; DependencyObject newScope = eventArgs.TargetKeyTipScope; if (newScope != null && !KeyTipService.GetIsKeyTipScope(newScope) && newScope != _currentGlobalScope) { throw new InvalidOperationException(SR.Get(SRID.ElementNotKeyTipScope)); } if (newScope == null && KeyTipService.GetIsKeyTipScope(exactMatchElement)) { newScope = exactMatchElement; } if (newScope != null) { // Show keytips for new scope in a dispatcher operation. Dispatcher.CurrentDispatcher.BeginInvoke( (Action)delegate() { ShowKeyTipsForScope(newScope, true); }, DispatcherPriority.Loaded); } else { LeaveKeyTipMode(oldFocusedElement == newFocusedElement /*restoreFocus*/); } } }