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); }
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)); }