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 }
protected override void OnLaunchedMenuClosed() { int pendingMenuCloseTimeoutId = Root.PendingMenuCloseTimeoutId; if (pendingMenuCloseTimeoutId != -1) { Browser.Window.ClearTimeout(pendingMenuCloseTimeoutId); } Root.PendingMenuCloseTimeoutId = -1; Root.PendingMenuCloseMenuLauncherStackIndex = -1; RemoveHighlight(); CloseToolTip(); ControlComponent comp = DisplayedComponent; if (comp.DisplayMode.StartsWith("Menu")) { // We know that if we're in a Menu, the structure must be Menu > MenuSection > MenuItem // and the DisplayedComponent must be the MenuItem Menu parentMenu = (Menu)comp.Parent.Parent; parentMenu.OpenSubMenuLauncher = null; } // If Properties.CommandMenuClose is not set, Root will not send the command to the root user, // so this won't hit page components. It is important that we do this though so that bugs like // O14:653413 are mitigated. comp.RaiseCommandEvent(Properties.CommandMenuClose, CommandType.MenuClose, null); base.OnLaunchedMenuClosed(); }
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); }
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); }
protected void ValidateAndSave() { Dictionary <string, string> commandDict = new Dictionary <string, string>(); // If value is not a valid menu item if (!SelectMenuItemById(_pendingMenuItemId)) { ControlComponent comp = DisplayedComponent; if (!Utility.IsTrue(CBProperties.AutoComplete)) { string menuitemid = GetMenuItem(_elmMediumInput.Value); if (!string.IsNullOrEmpty(menuitemid) && SelectMenuItemById(menuitemid)) { IsFreeForm = false; commandDict["IsFreeForm"] = "false"; commandDict["CommandValueId"] = _selectedControl.GetCommandValueId(); comp.RaiseCommandEvent(CBProperties.Command, CommandType.OptionSelection, commandDict); return; } } // If autocomplete was off, but we haven't returned yet, then the value was not a valid item in the menu // If free-form entry is allowed, send the value to the PageManager if (_allowFreeForm) { IsFreeForm = true; commandDict["IsFreeForm"] = "true"; commandDict["Value"] = _elmMediumInput.Value; StateProperties[ComboBoxCommandProperties.Value] = _elmMediumInput.Value; comp.RaiseCommandEvent(CBProperties.Command, CommandType.OptionSelection, commandDict); } // If free-form entry is not allowed, reset to the last valid value and stop else { ResetToPreviousValue(); return; } } // If the value is a valid menu item, send it as a CommandValueId to the PageManager else { IsFreeForm = false; commandDict["IsFreeForm"] = "false"; commandDict["CommandValueId"] = _selectedControl.GetCommandValueId(); DisplayedComponent.RaiseCommandEvent(CBProperties.Command, CommandType.OptionSelection, commandDict); } }
private void OnMouseover(HtmlEvent args) { OnBeginFocus(); if (!Enabled || MenuLaunched) { return; } HtmlElement target = args.TargetElement; HtmlElement relatedTarget = args.RelatedTarget; // Check if mouseover is to this element or not if (!(target == _elmMenu || target == _elmMenu16 || target == _elmMenu32)) { return; } while (!CUIUtility.IsNullOrUndefined(relatedTarget) && relatedTarget != target) { try { if (relatedTarget.NodeName.ToLower() == "body") { break; } } catch { // Firefox will sometimes start trying to iterate its own chrome nodes such as // the scrollbar which causes an access denied exception. If we get here, there's // nothing we can do, so just break out of the loop break; } relatedTarget = (HtmlElement)relatedTarget.ParentNode; } // Still moused over the flyout anchor, don't handle event if (relatedTarget == target) { return; } ControlComponent comp = DisplayedComponent; Anchor elm = (Anchor)comp.ElementInternal; LaunchMenuInternal(elm); string command = Properties.Command; if (!string.IsNullOrEmpty(command)) { comp.RaiseCommandEvent(command, CommandType.MenuCreation, null); } }
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])); } }
private void OnMouseenter(HtmlEvent args) { OnBeginFocus(); if (!Enabled || MenuLaunched) { return; } ControlComponent comp = DisplayedComponent; Anchor elm = (Anchor)comp.ElementInternal; LaunchMenuInternal(elm); string command = Properties.Command; if (!string.IsNullOrEmpty(command)) { comp.RaiseCommandEvent(command, CommandType.MenuCreation, null); } }
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); } } }
protected void HandleMouseBlur(HtmlEvent args) { RemoveHighlight(); 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; Dictionary <string, string> dict = this.StateProperties; dict["CommandValueId"] = this._commandValueId; dict["MenuItemId"] = this._menuItemId; string cmdtpe = Properties.CommandType; if (!string.IsNullOrEmpty(cmdtpe) && cmdtpe == "OptionSelection") { ct = CommandType.OptionPreviewRevert; } comp.RaiseCommandEvent(Properties.CommandRevert, ct, dict); }