public void Update(GameTime gameTime) { if (base.Count == 0) { return; } foreach (Control control in this) { if (control.Enabled) { control.Update(gameTime); } if (control.HasFocus) { control.HandleInput(); } if (control is ItemHolder) { ItemHolder holder = control as ItemHolder; holder.UpdateMouse(); /* * if (holder.isMouseInside()) * { * holder.HasFocus = true; * } * else * { * holder.HasFocus = false; * } */ } } if (InputHandler.LeftButtonPressed()) { if (ClickItem != null) { ClickItem(this, null); } } }
public void Update(GameTime gameTime) { if (enabled) { if (base.Count == 0) { return; } foreach (Control control in this) { if (control.Enabled) { control.Update(gameTime); } if (control.HasFocus) { control.HandleInput(); } if (control is ItemHolder) { ItemHolder holder = control as ItemHolder; holder.UpdateMouse(); /* * if (holder.isMouseInside()) * { * holder.HasFocus = true; * } * else * { * holder.HasFocus = false; * } */ } } if (InputHandler.LeftButtonPressed()) { if (ClickItem != null) { changedHolders = 0; ClickItem(this, null); //If no ItemHolder was modified, fire an event //that checks whether draggedItem should be dropped/disposed of if ((changedHolders == 0) && (DisposeItem != null)) { DisposeItem(this, null); } } } if (InputHandler.RightButtonPressed()) { if (draggedItem != null) { if (draggedItemLastSpot != null && RightClick != null) { RightClick(this, null); } else if (RightClickNull != null) { RightClickNull(this, null); } } else { if (RightClickEquip != null) { RightClickEquip(this, null); } } } if (draggedItem != null) { draggedItem.Update(gameTime); if (draggedItem.IsBeingDragged) { Vector2 newPosition = new Vector2(InputHandler.MouseState.X - draggedItem.Size.X / 2, InputHandler.MouseState.Y - draggedItem.Size.Y / 2); draggedItem.SetPosition(newPosition); } } } }