コード例 #1
0
ファイル: Control.cs プロジェクト: inoit/Tui.Net
        public void MouseEvent(MouseEvent @event)
        {
            @event.Position.X -= Position.X;
            @event.Position.Y -= Position.Y;

            foreach (var Control in Controls)
            {
                Control.MouseEvent(@event);
                if (@event.IsHandled)
                {
                    break;
                }
            }

            if (@event.IsHandled)
            {
                return;
            }

            if (@event.Position.X >= 0 && @event.Position.Y >= 0 && @event.Position.X < Size.Width &&
                @event.Position.Y < Size.Height)
            {
                if (@event.ButtonState > 0 && previousMouseEvent.ButtonState == 0)
                {
                    _isMouseDown = true;
                    Click?.Invoke(@event);
                }
                else if (@event.ButtonState == 0 && previousMouseEvent.ButtonState == 1)
                {
                    _isMouseDown = false;
                    Release?.Invoke(@event);
                }

                //if (_isMouseDown && [email protected](previousMouseEvent.Position))
                //{
                //	Dragged?.Invoke(previousMouseEvent.Position - @event.Position);
                //}

                previousMouseEvent = @event.Clone();
            }

            @event.Position.X += Position.X;
            @event.Position.Y += Position.Y;
        }