예제 #1
0
        private void OnMouseMoved(object sender, MouseEventArgs args)
        {
            if (_focusedControl != null)
                _focusedControl.OnMouseLeave(this, args);

            _focusedControl = FindControlAtPoint(Layout, args.Position);

            if (_focusedControl != null)
                _focusedControl.OnMouseEnter(this, args);

            Layout.OnMouseMoved(this, args);
        }
예제 #2
0
        public GuiManager(ViewportAdapter viewportAdapter, GraphicsDevice graphicsDevice)
        {
            _viewportAdapter = viewportAdapter;
            _inputManager = new InputListenerManager(viewportAdapter);
            _spriteBatch = new SpriteBatch(graphicsDevice);

            Controls = new List<GuiControl>();

            var mouseListener = _inputManager.AddListener<MouseListener>();
            mouseListener.MouseMoved += (sender, args) =>
            {
                if (_focusedControl != null)
                    _focusedControl.OnMouseLeave(this, args);

                _focusedControl = FindFocusedControl(args.Position);

                if (_focusedControl != null)
                    _focusedControl.OnMouseEnter(this, args);

                DelegateMouseEvent(args, c => c.OnMouseMoved(this, args));
            };
            mouseListener.MouseDown += (sender, args) => DelegateMouseEvent(args, c => c.OnMouseDown(this, args));
            mouseListener.MouseUp += (sender, args) => DelegateMouseEvent(args, c => c.OnMouseUp(this, args));
        }