当前位置: 首页>>代码示例>>C#>>正文


C# Base.CloseMenus方法代码示例

本文整理汇总了C#中Gwen.Control.Base.CloseMenus方法的典型用法代码示例。如果您正苦于以下问题:C# Base.CloseMenus方法的具体用法?C# Base.CloseMenus怎么用?C# Base.CloseMenus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gwen.Control.Base的用法示例。


在下文中一共展示了Base.CloseMenus方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnMouseClicked

        /// <summary>
        /// Mouse click handler.
        /// </summary>
        /// <param name="canvas">Canvas.</param>
        /// <param name="mouseButton">Mouse button number.</param>
        /// <param name="down">Specifies if the button is down.</param>
        /// <returns>True if handled.</returns>
        public bool OnMouseClicked(Base canvas, int mouseButton, bool down)
        {
            // If we click on a control that isn't a menu we want to close
            // all the open menus. Menus are children of the canvas.
            if (down && (null == HoveredControl || !HoveredControl.IsMenuComponent))
            {
                canvas.CloseMenus();
            }

            if (null == HoveredControl) return false;
            if (HoveredControl.GetCanvas() != canvas) return false;
            if (!HoveredControl.IsVisible) return false;
            if (HoveredControl == canvas) return false;

            if (mouseButton > MaxMouseButtons)
                return false;

            if (mouseButton == 0)
                m_KeyData.LeftMouseDown = down;
            else if (mouseButton == 1)
                m_KeyData.RightMouseDown = down;

            // Double click.
            // Todo: Shouldn't double click if mouse has moved significantly
            bool isDoubleClick = false;

            if (down &&
                m_LastClickPos.X == MousePosition.X &&
                m_LastClickPos.Y == MousePosition.Y &&
                (Platform.Neutral.GetTimeInSeconds() - m_LastClickTime[mouseButton]) < DoubleClickSpeed)
            {
                isDoubleClick = true;
            }

            if (down && !isDoubleClick)
            {
                m_LastClickTime[mouseButton] = Platform.Neutral.GetTimeInSeconds();
                m_LastClickPos = MousePosition;
            }

            if (down)
            {
                FindKeyboardFocus(HoveredControl);
            }

            HoveredControl.UpdateCursor();

            // This tells the child it has been touched, which
            // in turn tells its parents, who tell their parents.
            // This is basically so that Windows can pop themselves
            // to the top when one of their children have been clicked.
            if (down)
                HoveredControl.Touch();

            if (MouseClicked!=null)
                MouseClicked.Invoke(this, new EventArgs());

            #if GWEN_HOOKSYSTEM
            if (bDown)
            {
                if (Hook::CallHook(&Hook::BaseHook::OnControlClicked, HoveredControl, MousePosition.x,
                                   MousePosition.y))
                    return true;
            }
            #endif

            switch (mouseButton)
            {
                case 0:
                    {
                        if (DragAndDrop.OnMouseButton(HoveredControl, MousePosition.X, MousePosition.Y, down))
                            return true;

                        if (isDoubleClick)
                            HoveredControl.InputMouseDoubleClickedLeft(MousePosition.X, MousePosition.Y);
                        else
                            HoveredControl.InputMouseClickedLeft(MousePosition.X, MousePosition.Y, down);
                        return true;
                    }

                case 1:
                    {
                        if (isDoubleClick)
                            HoveredControl.InputMouseDoubleClickedRight(MousePosition.X, MousePosition.Y);
                        else
                            HoveredControl.InputMouseClickedRight(MousePosition.X, MousePosition.Y, down);
                        return true;
                    }
            }

            return false;
        }
开发者ID:akumetsuv,项目名称:flood,代码行数:99,代码来源:InputHandler.cs


注:本文中的Gwen.Control.Base.CloseMenus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。