public void Add(TSControl control) { if (control != null) { Controls.Add(control); control.ParentControlManager = this; if (control is TSLayout) ((TSLayout)control).ControlManager.Enabled = false; } }
public bool Remove(TSControl control) { if (control == null) return false; return Controls.Remove(control); }
protected void UpdateMouseEvent(GameTime gameTime) { TSControl mouseHoverControl = null; if (Enabled == false) return; mouseHoverControl = FindMouseHoverControl(); if (mouseHoverControl == null) if (lastMouseHoverControl != null) { lastMouseHoverControl.OnMouseLeave(null); if (lastMouseHoverControl is TSLayout) { TSLayout mouseHoverLayout = ((TSLayout)lastMouseHoverControl); mouseHoverLayout.ControlManager.Enabled = true; mouseHoverLayout.ControlManager.Update(gameTime); mouseHoverLayout.ControlManager.Enabled = false; } lastMouseHoverControl = null; } // truyền quyền Update cho layout con if ((mouseHoverControl != null) && (mouseHoverControl is TSLayout)) { TSLayout mouseHoverLayout = ((TSLayout)mouseHoverControl); mouseHoverLayout.ControlManager.Enabled = true; mouseHoverLayout.ControlManager.Update(gameTime); mouseHoverLayout.ControlManager.Enabled = false; lastMouseHoverControl = mouseHoverControl; } // Kiểm tra sự kiện di chuyển của chuột if ((mouseHoverControl != null) && (mouseHoverControl != lastMouseHoverControl)) mouseHoverControl.OnMouseEnter(null); if ((lastMouseHoverControl != null) && (mouseHoverControl != lastMouseHoverControl)) lastMouseHoverControl.OnMouseLeave(null); if ((mouseHoverControl != null) && (lastMouseHoverControl != null) && (lastMouseHoverControl == mouseHoverControl)) mouseHoverControl.OnMouseMove(null); lastMouseHoverControl = mouseHoverControl; // Kiểm tra sự kiện nhấn của chuột if (TSInputHandler.MouseState.LeftButton == ButtonState.Released) if (lastMousePressControl != null) { lastMousePressControl.OnMouseUp(null); lastMousePressControl = null; return; } if (mouseHoverControl == null) return; if (TSInputHandler.LastMouseState.LeftButton == ButtonState.Pressed) if (mouseHoverControl == lastMousePressControl) { mouseHoverControl.OnMouseDown(null); } else { mouseHoverControl.OnMouseClick(null); lastMousePressControl = mouseHoverControl; if ((focusingControl != null) && (focusingControl == mouseHoverControl)) { return; } if (focusingControl != null) focusingControl.OnFocusLeave(null); focusingControl = mouseHoverControl; focusingControl.OnFocusEnter(null); } }
public void Add(TSControl control) { ControlManager.Add(control); }