/// <summary> /// Shows popup if there is one, and sets the number of clicks to close /// to two. /// </summary> internal void Select() { if (!this.isPopUpShown && this.numMenuItems > 0 && this.isEnabled) { if (PopUpOpen != null) { PopUpOpen.Invoke(this); } this.isPopUpShown = true; this.popUpMenu.Populate(); if (Parent.GetType() == typeof(MenuBar)) // MenuBar parent { this.popUpMenu.X = AbsolutePosition.X; this.popUpMenu.Y = AbsolutePosition.Y + Height - 1; } else // PopUpMenu parent { this.popUpMenu.X = Parent.AbsolutePosition.X + Parent.Width - 1; this.popUpMenu.Y = AbsolutePosition.Y; } GUIManager.SetFocus(this.popUpMenu); GUIManager.Add(this.popUpMenu); AddHighlight(); this.numClicks = 0; } else { this.popUpMenu.BringToTop(); } }
/// <summary> /// Either button is released. /// </summary> /// <param name="args">Mouse event arguments.</param> protected void OnButtonUp(MouseEventArgs args) { if (args.Button == MouseButtons.Left) { this.isTopPressed = false; this.isBottomPressed = false; this.isTopOver = false; this.isBottomOver = false; // Get focus back GUIManager.SetFocus(this); } }
/// <summary> /// Finishes dragging the thumb. /// </summary> /// <param name="args">Mouse event arguments.</param> protected void OnThumbUp(MouseEventArgs args) { if (args.Button == MouseButtons.Left) { this.draggingThumb = false; // Check if hover state should be shown if (this.thumb.CheckCoordinates(args.Position.X, args.Position.Y)) { this.thumb.CurrentSkinState = SkinState.Hover; } else { this.thumb.CurrentSkinState = SkinState.Normal; } // Get focus back from thumb GUIManager.SetFocus(this); } }
/// <summary> /// Allows tabbing between child controls. /// </summary> /// <param name="args">Key event arguments.</param> protected override void KeyUpIntercept(KeyEventArgs args) { base.KeyUpIntercept(args); if (args.Key == Keys.Tab && IsChild(GUIManager.GetFocus())) { List <UIComponent> controls = this.viewPort.Controls; bool backwards = args.Shift; int index = 0; foreach (UIComponent control in controls) { if (control.IsChild(GUIManager.GetFocus())) { UIComponent nextControl; int nextIndex = index; while (true) { // Loop round the list if necessary if (backwards) { if (nextIndex > 0) { nextIndex--; } else { nextIndex = controls.Count - 1; } } else { if ((nextIndex + 1) < controls.Count) { nextIndex++; } else { nextIndex = 0; } } nextControl = controls[nextIndex]; // Set focus to next control if (nextControl.CanHaveFocus && nextControl != this.backgroundMovableArea) { GUIManager.SetFocus(nextControl); break; } else if (nextIndex == index) // Exit loop if coming back to the same control { break; } } break; } index++; } } }