internal override bool FocusNext(HtmlEvent evt) { if (!Visible) return false; Focused = Control.FocusNext(evt); return Focused; }
/// <summary> /// Obsolete API will be removed soon /// </summary> /// <param name="evt">The DomEvent that triggered the launch(usually a mouse click)</param> internal bool LaunchContextMenu(HtmlElement targetElement, HtmlEvent evt) { _targetElement = targetElement; _launchPosition = GetMenuPosition(evt); LaunchMenu(null); Menu.FocusOnFirstItem(evt); return true; }
/// <summary> /// Invoked when the Menu is opened /// </summary> protected void OnMenuButtonClick(HtmlEvent evt) { if (!Enabled) return; LaunchContextMenu(null, evt); DisplayedComponent.RaiseCommandEvent(Properties.CommandMenuOpen, CommandType.MenuCreation, null); }
private void RibbonStartInit(HtmlEvent args) { if (!NativeUtility.RibbonReadyForInit()) return; if (!CUIUtility.IsNullOrUndefined(args)) _ribbon.SetField<bool>("initialTabSelectedByUser", true); Utility.CancelEventUtility(args, false, true); if (_ribbon.GetField<bool>("initStarted")) return; _ribbon.SetField<bool>("initStarted", true); // Get the name of the tab that was just selected Anchor tab = (Anchor)args.CurrentTargetElement; ListItem parent = (ListItem)tab.ParentNode; string initialTabId = parent.Id.Substring(0, parent.Id.IndexOf("-title")); string firstTabId = ""; if (!string.IsNullOrEmpty(initialTabId)) { firstTabId = _ribbon.GetField<string>("initialTabId"); _ribbon.SetField<string>("initialTabId", initialTabId); } _ribbon.SetField<bool>("buildMinimized", false); if(!string.IsNullOrEmpty(initialTabId)) { NativeUtility.RibbonOnStartInit(_ribbon); ListItem oldTab = (ListItem)Browser.Document.GetById(firstTabId + "-title"); if (!CUIUtility.IsNullOrUndefined(oldTab)) oldTab.ClassName = "ms-cui-tt"; ListItem newTab = (ListItem)Browser.Document.GetById(initialTabId + "-title"); if (!CUIUtility.IsNullOrUndefined(newTab)) newTab.ClassName = "ms-cui-tt ms-cui-tt-s"; } RibbonInitFunc1(); }
/// <summary> /// Handle when a tab title is clicked. /// This causes this tab to become the selected one. /// </summary> /// <param name="evt"></param> private void OnTitleClick(HtmlEvent args) { #if PERF_METRICS PMetrics.PerfMark(PMarker.perfCUIRibbonTabSwitchWarmStart); #endif Utility.CancelEventUtility(args, false, true); _shouldProcessSingleClick = true; // If the tab is selected, then we need to make sure that the user didn't try to double click // So, we have to wait a bit to let the the double click event fire. // Double clicking only works on the selected tab so if this tab is not selected, then // we can process the single click right away. if (Selected) { Browser.Window.SetTimeout(TitleClickCallback, 500); } else { TitleClickCallback(); } }
private void OnKeypress(HtmlEvent evt) { if (!CUIUtility.IsNullOrUndefined(evt)) { if (evt.KeyCode == (int)Key.Enter) { OnChange(evt); Utility.CancelEventUtility(evt, false, true); } } }
private void OnMouseover(HtmlEvent args) { OnBeginFocus(); if (!Enabled) return; if (string.IsNullOrEmpty(Properties.CommandPreview)) return; DisplayedComponent.RaiseCommandEvent(Properties.CommandPreview, CommandType.Preview, StateProperties); }
private void OnFocus(HtmlEvent args) { OnBeginFocus(); if (!Enabled) return; _elmDefaultInput.PerformSelect(); Root.LastFocusedControl = this; }
private void OnKeyDown(HtmlEvent args) { if (!CUIUtility.IsNullOrUndefined(args)) { if ((Key)args.KeyCode == Key.Enter) OnLabelClick(args); } }
internal override void FocusOnLastItem(HtmlEvent evt) { int count = Children.Count; if (count == 0) return; if (_focusedIndex > -1) ((Component)Children[_focusedIndex]).ResetFocusedIndex(); _focusedIndex = count - 1; ((Component)Children[_focusedIndex]).FocusOnLastItem(evt); }
// No matter where we are in the stack, a click anywhere other than on a menu should close all menus public override void OnModalBodyClick(HtmlEvent args) { Root.CloseAllMenus(); }
public override void OnModalKeyPress(HtmlEvent args) { if (!CUIUtility.IsNullOrUndefined(args)) { if ((((Root.TextDirection == Direction.LTR && args.KeyCode == (int)Key.Left) || (Root.TextDirection == Direction.RTL && args.KeyCode == (int)Key.Right)) && (DisplayedComponent.DisplayMode).StartsWith("Menu")) || args.KeyCode == (int)Key.Esc) { Root.CloseMenuStack(this); return; } } if (IsGroupPopup) { if (_focusSet) return; if (Menu.SetFocusOnFirstControl()) _focusSet = true; Utility.CancelEventUtility(args, false, true); } else { base.OnModalKeyPress(args); } }
private void OnKeyPress(HtmlEvent args) { CloseToolTip(); if (!Enabled) return; int key = args.KeyCode; if (MenuLaunched) { if ((Root.TextDirection == Direction.LTR && key == (int)Key.Right) || (Root.TextDirection == Direction.RTL && key == (int)Key.Left)) Menu.FocusOnFirstItem(args); } else { if (key == (int)Key.Enter || key == (int)Key.Space || (((Root.TextDirection == Direction.LTR && key == (int)Key.Right) || (Root.TextDirection == Direction.RTL && key == (int)Key.Left)) && (!args.CtrlKey || !args.ShiftKey))) { LaunchedByKeyboard = true; ControlComponent comp = DisplayedComponent; Anchor elm = (Anchor)comp.ElementInternal; string command = Properties.Command; if (!string.IsNullOrEmpty(command)) { comp.RaiseCommandEvent(command, CommandType.MenuCreation, null); } LaunchMenuInternal(elm); } } }
private void OnMenuMouseout(HtmlEvent args) { OnEndFocus(); if (Utility.IsDescendantOf(DisplayedComponent.ElementInternal, args.RelatedTarget)) return; if (MenuLaunched) { // If mouse is over any menu that is nested in this one, don't close int mlIndex = Root.MenuLauncherStack.IndexOf(this); for (int i = mlIndex; i < Root.MenuLauncherStack.Count; i++) { if (Utility.IsDescendantOf(Root.MenuLauncherStack[i].Menu.ElementInternal, args.RelatedTarget)) return; } SetCloseMenuStackTimeout(); } RemoveHighlight(); }
private void OnMouseleave(HtmlEvent args) { OnEndFocus(); if (!Enabled) return; if (MenuLaunched) { // If mouse is over any menu that is nested in this one, don't close int mlIndex = Root.MenuLauncherStack.IndexOf(this); for (int i = mlIndex; i < Root.MenuLauncherStack.Count; i++) { if (Utility.IsDescendantOf(((MenuLauncher)Root.MenuLauncherStack[i]).Menu.ElementInternal, args.ToElement)) return; } SetCloseMenuStackTimeout(); } }
protected void OnArrowButtonKeyPress(HtmlEvent args) { CloseToolTip(); if (!Enabled) return; int key = args.KeyCode; if (key == (int)Key.Enter || key == (int)Key.Space || key == (int)Key.Down) { LaunchedByKeyboard = true; LaunchMenuInternal(args); } }
protected override void OnClick(HtmlEvent args) { // evt.PreventDefault() will prevent checkbox state from being toggled CloseToolTip(); if (!Enabled) return; CommandType ct = CommandType.IgnoredByMenu; ControlComponent comp = DisplayedComponent; // Choose appropriate check box switch (comp.DisplayMode) { case "Small": StateProperties[CheckBoxCommandProperties.On] = _elmSmallCheckboxInput.Checked.ToString(); break; case "Medium": StateProperties[CheckBoxCommandProperties.On] = _elmMediumCheckboxInput.Checked.ToString(); break; default: EnsureValidDisplayMode(comp.DisplayMode); return; } // Send command comp.RaiseCommandEvent(Properties.Command, ct, StateProperties); if (Root.PollForState) PollForStateAndUpdate(); else SetState(Utility.IsTrue(StateProperties[CheckBoxCommandProperties.On])); }
internal override bool FocusPrevious(HtmlEvent evt) { int count = Children.Count; if (_focusedIndex == -1) _focusedIndex = count - 1; int i = _focusedIndex; while (i > -1) { Component comp = Children[i]; if (comp.FocusPrevious(evt)) { // If focus is not moving, don't reset the focus of the menu item if (i != _focusedIndex) { ((Component)Children[_focusedIndex]).ResetFocusedIndex(); _focusedIndex = i; } return true; } i--; } if (count > 0) ((Component)Children[_focusedIndex]).ResetFocusedIndex(); _focusedIndex = -1; return false; }
private void OnLabelClick(HtmlEvent args) { Utility.CancelEventUtility(args, false, true); CloseToolTip(); if (!Enabled) return; Root.LastFocusedControl = this; // Toggle the checkbox and send the command SetState(!_elmMediumCheckboxInput.Checked); OnClick(args); }
internal override bool FocusNext(HtmlEvent evt) { if (_focusedIndex == -1) _focusedIndex = 0; int i = _focusedIndex; while (i < Children.Count) { Component comp = Children[i]; if (comp.FocusNext(evt)) { // If focus is not moving, don't reset the focus of the menu item if (i != _focusedIndex) { if (!CUIUtility.IsNullOrUndefined(Children[_focusedIndex])) ((Component)Children[_focusedIndex]).ResetFocusedIndex(); _focusedIndex = i; } return true; } i++; } if (Children.Count > 0) ((Component)Children[_focusedIndex]).ResetFocusedIndex(); _focusedIndex = -1; return false; }
private void OnChange(HtmlEvent args) { CloseToolTip(); if (!Enabled) return; // Send out the command StateProperties[TextBoxCommandProperties.Value] = this.Value; DisplayedComponent.RaiseCommandEvent(Properties.Command, CommandType.General, StateProperties); if (Root.PollForState) PollForStateAndUpdate(); else SetState(null); }
protected void OnArrowButtonClick(HtmlEvent evt) { bool enabled = Enabled; #if PERF_METRICS if (enabled) PMetrics.PerfMark(PMarker.perfCUIDropDownOnArrowButtonClickStart); #endif CloseToolTip(); Utility.CancelEventUtility(evt, false, true); if (!enabled) return; Root.LastFocusedControl = this; LaunchMenuInternal(evt); #if PERF_METRICS PMetrics.PerfMark(PMarker.perfCUIDropDownOnArrowButtonClickEnd); #endif }
private void OnBlur(HtmlEvent args) { OnEndFocus(); if (!Enabled) return; }
protected virtual void LaunchMenuInternal(HtmlEvent args) { if (LaunchMenu(_elmMediumBtnA, new Action(SendMenuCreationCommandEvent))) { SendMenuCreationCommandEvent(); } }
private void OnMouseout(HtmlEvent args) { OnEndFocus(); if (!Enabled) return; if (string.IsNullOrEmpty(Properties.CommandRevert)) return; DisplayedComponent.RaiseCommandEvent(Properties.CommandRevert, CommandType.PreviewRevert, StateProperties); }
protected void OnArrowButtonKeyboardFocus(HtmlEvent args) { Root.LastFocusedControl = this; OnArrowButtonFocus(args); }
/// <summary> /// Handle when a tab title is selected via keyboard. /// </summary> /// <param name="evt"></param> private void OnTitleKeyPress(HtmlEvent args) { if (!CUIUtility.IsNullOrUndefined(args)) { int key = args.KeyCode; if (key == (int)Key.Enter) { _launchedByKeyboard = true; Utility.CancelEventUtility(args, false, true); OnTitleClick(args); } } }
protected void OnArrowButtonFocus(HtmlEvent args) { OnBeginFocus(); if (!Enabled) return; Highlight(); }
private void OnTitleDblClick(HtmlEvent args) { _shouldProcessSingleClick = false; Utility.CancelEventUtility(args, false, true); // If the ribbon is not minimized, double-clicking on a tab will minimize it Ribbon.MinimizedInternal = true; Ribbon.RefreshInternal(); }
protected void OnArrowButtonBlur(HtmlEvent args) { OnEndFocus(); if (!Enabled || MenuLaunched) return; RemoveHighlight(); }