private void OnBlur(HtmlEvent args) { OnEndFocus(); if (!Enabled) { return; } ControlComponent comp = DisplayedComponent; if (comp is MenuItem) { ((MenuItem)comp).Focused = false; } if (string.IsNullOrEmpty(Properties.CommandRevert)) { return; } CommandType ct = CommandType.PreviewRevert; string cmdtpe = Properties.CommandType; if (!string.IsNullOrEmpty(cmdtpe) && cmdtpe == "OptionSelection") { ct = CommandType.OptionPreviewRevert; StateProperties[ToggleButtonCommandProperties.CommandValueId] = _commandValueId; } comp.RaiseCommandEvent(Properties.CommandRevert, ct, StateProperties); }
internal override bool FocusNext(HtmlEvent evt) { int moveCount = 1; if (!CUIUtility.IsNullOrUndefined(evt) && evt.KeyCode == (int)Key.Down) { moveCount = ColumnSize; } if (_focusedIndex + moveCount < 0) { _focusedIndex = -1; moveCount = 1; } if (_focusedIndex + moveCount < _colorCells.Count) { SetFocusOnCell(_focusedIndex + moveCount); return(true); } RemoveHighlighting(); _focusedIndex -= _colorCells.Count; return(false); }
protected void HandleMouseFocus(HtmlEvent args) { OnBeginFocus(); if (!Enabled) { return; } ControlComponent comp = DisplayedComponent; if (comp is MenuItem) { ((MenuItem)comp).Focused = true; } if (string.IsNullOrEmpty(Properties.CommandPreview)) { return; } Dictionary <string, string> dict = this.StateProperties; dict["CommandValueId"] = this._commandValueId; dict["MenuItemId"] = this._menuItemId; CommandType ct = CommandType.Preview; string cmdtpe = Properties.CommandType; if (!string.IsNullOrEmpty(cmdtpe) && cmdtpe == "OptionSelection") { ct = CommandType.OptionPreview; } comp.RaiseCommandEvent(Properties.CommandPreview, ct, dict); }
private void OnMouseout(HtmlEvent args) { OnEndFocus(); if (!Enabled) { return; } if (string.IsNullOrEmpty(Properties.CommandRevert)) { return; } CommandType ct = CommandType.PreviewRevert; string cmdtpe = Properties.CommandType; if (!string.IsNullOrEmpty(cmdtpe) && cmdtpe == "OptionSelection") { ct = CommandType.OptionPreviewRevert; StateProperties[ToggleButtonCommandProperties.CommandValueId] = _commandValueId; } DisplayedComponent.RaiseCommandEvent(Properties.CommandRevert, ct, StateProperties); }
/// <summary> /// Handle the keypress of the help key (F1) /// </summary> /// <param name="evt"></param> /// <owner alias="HillaryM" /> protected void OnHelpKeyPress(HtmlEvent args) { if (!CUIUtility.IsNullOrUndefined(_toolTip)) { _toolTip.OnKeyPress(args); } }
protected void OnInputBlur(HtmlEvent args) { // O14:574004 - we need to clear the pending autocomplete on blur // if the user left, they don't need autocomplete ClearPendingAutoComplete(); OnArrowButtonBlur(args); }
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 OnSelectAllCbxClick(HtmlEvent args) { if (_selectionCount == 4) { for (int idx = 1; idx < 5; idx++) { Input itemCbx = _itemCbxCache[idx]; if (_itemSelected[idx]) { itemCbx.Checked = false; ToggleSelectionState(itemCbx, idx, false); } } } else { for (int idx = 1; idx < 5; idx++) { Input itemCbx = _itemCbxCache[idx]; if (!_itemSelected[idx]) { itemCbx.Checked = true; ToggleSelectionState(itemCbx, idx, true); } } } // Signal state changed so Ribbon will recompute state PageManager.Instance.CommandDispatcher.ExecuteCommand(Commands.CommandIds.ApplicationStateChanged, null); }
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 gallery item if (i != _focusedIndex) { ((Component)Children[_focusedIndex]).ResetFocusedIndex(); _focusedIndex = i; } return(true); } i++; } ((Component)Children[_focusedIndex]).ResetFocusedIndex(); _focusedIndex = -1; return(false); }
private void OnCellClick(HtmlEvent args) { Utility.CancelEventUtility(args, false, true); if (!Enabled) { return; } HtmlElement element = args.TargetElement; HtmlElement cell = Utility.GetNearestContainingParentElementOfType(element, "td"); ColorPickerResult result = GetColorPickerResultFromSelectedCell(cell); Dictionary <string, string> dict = new Dictionary <string, string>(); dict[ColorPickerCommandProperties.Color] = result.Color; dict[ColorPickerCommandProperties.Style] = result.Style; // We don't want to send a preview revert command since the user has picked one // by clicking. CancelClickPreviewRevert(); DisplayedComponent.RaiseCommandEvent(Properties.Command, CommandType.General, dict); }
protected void OnFocus(HtmlEvent args) { OnBeginFocus(); if (!Enabled) { return; } Root.LastFocusedControl = this; if (string.IsNullOrEmpty(Properties.CommandPreview)) { return; } CommandType ct = CommandType.Preview; string cmdtpe = Properties.CommandType; StateProperties[GalleryButtonCommandProperties.CommandValueId] = Properties.CommandValueId; if (!CUIUtility.IsNullOrUndefined(cmdtpe) && cmdtpe == "OptionSelection") { ct = CommandType.OptionPreview; } DisplayedComponent.RaiseCommandEvent(Properties.CommandPreview, ct, StateProperties); }
private void OnKeydown(HtmlEvent args) { if (!Enabled) { return; } if (_keySpin) { return; } _changedByMouse = false; int key = args.KeyCode; if (key == (int)Key.Up) { StartSpin(INC); Utility.EnsureCSSClassOnElement(_elmDefaultUpArw, "ms-cui-spn-btnup-down"); } else if (key == (int)Key.Down) { StartSpin(DEC); Utility.EnsureCSSClassOnElement(_elmDefaultDownArw, "ms-cui-spn-btndown-down"); } else { return; } _keySpin = true; }
protected void OnKeyPress(HtmlEvent args) { if (!Enabled) { return; } // Make OACR happy if (CUIUtility.IsNullOrUndefined(args)) { return; } int key = args.KeyCode; if (key == (int)Key.Enter || key == (int)Key.Space || key == (int)Key.Down) { LaunchedByKeyboard = true; if (MenuLaunched) { CloseMenu(); } else { LaunchJewelMenu(); } Utility.CancelEventUtility(args, false, true); } // No need to check for escape to close here because the modal element will do that for us (O14:391733) }
protected override void LaunchMenuInternal(HtmlEvent args) { bool launchSucceeded = false; Root.FixedPositioningEnabled = false; switch (DisplayedComponent.Title) { case "Large": launchSucceeded = LaunchMenu(_elmLargeBtn, new Action(SendMenuCreationCommandEvent)); break; case "Medium": launchSucceeded = LaunchMenu(_elmMediumBtn, new Action(SendMenuCreationCommandEvent)); break; case "Small": launchSucceeded = LaunchMenu(_elmSmallBtn, new Action(SendMenuCreationCommandEvent)); break; } if (launchSucceeded) { // _selectedControl.FocusOnDisplayedComponent(); // Send out the menu launch command if it has been specified SendMenuCreationCommandEvent(); } }
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(); }
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); } }
protected override void OnClick(HtmlEvent evt) { bool enabled = Enabled; #if PERF_METRICS if (enabled && !MenuLaunched) { PMetrics.PerfMark(PMarker.perfCUIFlyoutAnchorOnClickStart); } #endif CloseToolTip(); Utility.CancelEventUtility(evt, false, true); if (!enabled || MenuLaunched) { return; } Root.LastCommittedControl = this; ControlComponent comp = DisplayedComponent; Anchor elm = (Anchor)comp.ElementInternal; LaunchMenuInternal(elm); if (!string.IsNullOrEmpty(Properties.Command)) { comp.RaiseCommandEvent(Properties.Command, CommandType.MenuCreation, null); } #if PERF_METRICS PMetrics.PerfMark(PMarker.perfCUIFlyoutAnchorOnClickEnd); #endif }
internal void OnClick(HtmlEvent evt) { if (this.Root != null) { Root.CloseOpenTootips(); } }
internal override bool FocusPrevious(HtmlEvent evt) { int moveCount = 1; if (!CUIUtility.IsNullOrUndefined(evt) && evt.KeyCode == (int)Key.Up) { moveCount = ColumnSize; } if (_focusedIndex < 0) { _focusedIndex += _colorCells.Count + moveCount; } if (_focusedIndex >= moveCount) { SetFocusOnCell(_focusedIndex - moveCount); return(true); } RemoveHighlighting(); _focusedIndex -= moveCount; return(false); }
private void OnItemCbxClick(HtmlEvent args) { Input cbx = (Input)args.CurrentTargetElement; int itemId = Int32.Parse(cbx.GetAttribute("itemId")); if (_itemSelected[itemId]) { if (_selectionCount == 4) { _selectAllCheckbox.Checked = false; } ToggleSelectionState(cbx, itemId, false); } else { if (_selectionCount == 3) { _selectAllCheckbox.Checked = true; } ToggleSelectionState(cbx, itemId, true); } // Signal state changed so Ribbon will recompute state PageManager.Instance.CommandDispatcher.ExecuteCommand(Commands.CommandIds.ApplicationStateChanged, null); }
public virtual void OnModalBodyClick(HtmlEvent evt) { // Firefox specific fix Utility.CancelEventUtility(evt, false, true); LaunchedByKeyboard = false; // remember we're using the mouse Root.CloseMenuStack(this); }
private void OnCellClick(HtmlEvent evt) { if (!CUIUtility.IsNullOrUndefined(typeof(PMetrics))) { PMetrics.PerfMark(PMarker.perfCUIRibbonInsertTableOnClickStart); } Utility.CancelEventUtility(evt, false, true); if (!Enabled) { return; } Div element = GetOuterDiv(evt.TargetElement); int idx = GetIndexFromElement(element); int column = GetColFromIndex(idx); int row = GetRowFromIndex(idx); // We don't want to send a preview revert command since the user has picked one // by clicking. CancelClickPreviewRevert(); CommandProperties[InsertTableCommandProperties.Rows] = (row + 1).ToString(); CommandProperties[InsertTableCommandProperties.Columns] = (column + 1).ToString(); DisplayedComponent.RaiseCommandEvent(Properties.Command, CommandType.General, CommandProperties); if (!CUIUtility.IsNullOrUndefined(typeof(PMetrics))) { PMetrics.PerfMark(PMarker.perfCUIRibbonInsertTableOnClickEnd); } }
protected virtual void LaunchMenuInternal(HtmlEvent args) { if (LaunchMenu(_elmMediumBtnA, new Action(SendMenuCreationCommandEvent))) { SendMenuCreationCommandEvent(); } }
protected void OnBlur(HtmlEvent args) { OnEndFocus(); if (!Enabled) { return; } if (string.IsNullOrEmpty(Properties.CommandRevert)) { return; } CommandType ct = CommandType.PreviewRevert; string cmdtpe = Properties.CommandType; if (!CUIUtility.IsNullOrUndefined(cmdtpe) && cmdtpe == "OptionSelection") { ct = CommandType.OptionPreviewRevert; StateProperties[GalleryButtonCommandProperties.CommandValueId] = Properties.CommandValueId; } DisplayedComponent.RaiseCommandEvent(Properties.CommandRevert, ct, StateProperties); }
private void OnFocus(HtmlEvent args) { OnBeginFocus(); if (!Enabled) { return; } }
/// <summary> /// By default this places the menu where mouse was clicked /// </summary> /// <param name="comp"></param> protected virtual Bounds GetMenuPosition(HtmlEvent evt) { Bounds b = new Bounds(0, 0, 0, 0); b.Y = evt.ClientY; b.X = evt.ClientX; return(b); }
private void OnBlur(HtmlEvent args) { OnEndFocus(); if (!Enabled) { return; } }
private void OnGlassClick(HtmlEvent args) { if (_currentlyOpenedMenu != null) { _currentlyOpenedMenu.CloseMenu(); } // The MenuClose event handler above will take care of removing the glass and resetting _currentlyOpenedMenu }
/// <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); }
IHtmlElement IHtmlElement.OnClient(HtmlEvent e, string script) { foreach (var item in Elements) { item.OnClient(e, script); } return(this); }
/// <summary> /// Attach an event handler to the element. /// </summary> /// <param name="eventName">The HTML script event name.</param> /// <param name="handler">The event handler.</param> public void AttachEvent(HtmlEvent eventName, EventHandler<HtmlEventArgs> handler) { AttachEvent(eventName.ScriptPropertyName(), handler); }