示例#1
0
 internal override bool FocusNext(HtmlEvent evt)
 {
     if (!Visible)
         return false;
     Focused = Control.FocusNext(evt);
     return Focused;
 }
示例#2
0
 /// <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;
 }
示例#3
0
        /// <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);
        }
示例#4
0
文件: page.cs 项目: modulexcite/IL2JS
        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();
        }
示例#5
0
文件: tab.cs 项目: modulexcite/IL2JS
        /// <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();
            }
        }
示例#6
0
 private void OnKeypress(HtmlEvent evt)
 {
     if (!CUIUtility.IsNullOrUndefined(evt))
     {
         if (evt.KeyCode == (int)Key.Enter)
         {
             OnChange(evt);
             Utility.CancelEventUtility(evt, false, true);
         }
     }
 }
示例#7
0
        private void OnMouseover(HtmlEvent args)
        {
            OnBeginFocus();
            if (!Enabled)
                return;

            if (string.IsNullOrEmpty(Properties.CommandPreview))
                return;

            DisplayedComponent.RaiseCommandEvent(Properties.CommandPreview,
                                                 CommandType.Preview,
                                                 StateProperties);
        }
示例#8
0
        private void OnFocus(HtmlEvent args)
        {
            OnBeginFocus();
            if (!Enabled)
                return;

            _elmDefaultInput.PerformSelect();
            Root.LastFocusedControl = this;
        }
示例#9
0
 private void OnKeyDown(HtmlEvent args)
 {
     if (!CUIUtility.IsNullOrUndefined(args))
     {
         if ((Key)args.KeyCode == Key.Enter)
             OnLabelClick(args);
     }
 }
示例#10
0
        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);
        }
示例#11
0
 // 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();
 }
示例#12
0
        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);
            }
        }
示例#13
0
        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);
                }
            }
        }
示例#14
0
        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();
        }
示例#15
0
        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();
            }
        }
示例#16
0
        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);
            }
        }
示例#17
0
        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]));
        }
示例#18
0
        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;
        }
示例#19
0
        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);
        }
示例#20
0
        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;
        }
示例#21
0
        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);
        }
示例#22
0
        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
        }
示例#23
0
 private void OnBlur(HtmlEvent args)
 {
     OnEndFocus();
     if (!Enabled)
         return;
 }
示例#24
0
 protected virtual void LaunchMenuInternal(HtmlEvent args)
 {
     if (LaunchMenu(_elmMediumBtnA, new Action(SendMenuCreationCommandEvent)))
     {
         SendMenuCreationCommandEvent();
     }
 }
示例#25
0
        private void OnMouseout(HtmlEvent args)
        {
            OnEndFocus();
            if (!Enabled)
                return;

            if (string.IsNullOrEmpty(Properties.CommandRevert))
                return;

            DisplayedComponent.RaiseCommandEvent(Properties.CommandRevert,
                                                 CommandType.PreviewRevert,
                                                 StateProperties);
        }
示例#26
0
 protected void OnArrowButtonKeyboardFocus(HtmlEvent args)
 {
     Root.LastFocusedControl = this;
     OnArrowButtonFocus(args);
 }
示例#27
0
文件: tab.cs 项目: modulexcite/IL2JS
 /// <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);
         }
     }
 }
示例#28
0
 protected void OnArrowButtonFocus(HtmlEvent args)
 {
     OnBeginFocus();
     if (!Enabled)
         return;
     Highlight();
 }
示例#29
0
文件: tab.cs 项目: modulexcite/IL2JS
        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();
        }
示例#30
0
 protected void OnArrowButtonBlur(HtmlEvent args)
 {
     OnEndFocus();
     if (!Enabled || MenuLaunched)
         return;
     RemoveHighlight();
 }