protected virtual void OnClick(ListBoxEventArgs e) { ListBoxEventHandler handler = Click; if (handler != null) { if (ParentScreen.Name == Storage.Instance.CurrentScreen.Name) { handler(this, e); } } }
public void IsClicked(MouseState state, Vector2 cursorPos) { if (Visible) { HoverId = -1; if (!ListScroll.IsClicked(state, cursorPos, Visible)) { if (ListBoxArea.Contains(cursorPos.X - this.ParentViewport.Viewport.X, cursorPos.Y - this.ParentViewport.Viewport.Y)) { for (int i = 0; i < Items.Count; i++) { Rectangle tmpRect = new Rectangle((int)CurrentPosition.X, (int)CurrentPosition.Y + (i * 16) + _offsetY, Width, 16); if (!Clicked && state.LeftButton == ButtonState.Pressed) { if (tmpRect.Contains(cursorPos.X - this.ParentViewport.Viewport.X, cursorPos.Y - this.ParentViewport.Viewport.Y)) { Clicked = true; } } else if (Clicked && state.LeftButton == ButtonState.Released) { if (tmpRect.Contains(cursorPos.X - this.ParentViewport.Viewport.X, cursorPos.Y - this.ParentViewport.Viewport.Y)) { UpdateClicked(i); ListBoxEventArgs args = new ListBoxEventArgs(this.Id, this.Name, this.ParentForm.Id, this.ParentScreen.Id, Items[i]); OnClick(args); Clicked = false; } } if (tmpRect.Contains(cursorPos.X - this.ParentViewport.Viewport.X, cursorPos.Y - this.ParentViewport.Viewport.Y)) { HoverId = i; } } } else { Clicked = false; } } } }