コード例 #1
0
ファイル: Container.cs プロジェクト: LexTheGreat/EclipseSharp
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Tells the widget that the left mouse has been pressed on top of the widget
        /// </summary>
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        protected internal override void OnLeftMousePressed(MouseButtonEventArgs e)
        {
            // Adjust the mouse position of the event
            e.X = (int)(e.X - Position.X);
            e.Y = (int)(e.Y - Position.Y);

            // Check if the mouse is on top of an widget
            Widget widget = null;

            if (MouseOnWhichWidget(ref widget, e.X, e.Y))
            {
                // Focus the widget
                FocusWidget(widget);

                // Check if the widget is a container
                if (widget.m_Container)
                {
                    // If another widget was focused then unfocus it now
                    if ((m_FocusedWidget != null) && (m_FocusedWidget != widget))
                    {
                        widget.m_Focused = false;
                        widget.OnWidgetUnfocused();
                        m_FocusedWidget = null;
                    }
                }

                widget.OnLeftMousePressed(e);
            }
            else // The mouse didn't went down on an widget, so unfocus the focused widget
            {
                UnfocusWidgets();
            }
        }