Esempio n. 1
0
        /// <summary>
        /// Handles the timing for a flashing cursor.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // Update flashing cursor
            if (GUIManager.GetFocus() != this)
            {
                if (this.label.IsCursorShown)
                {
                    this.label.IsCursorShown = false;
                    this.seconds             = 0;
                }
            }
            else
            {
                this.seconds += gameTime.ElapsedGameTime.TotalSeconds;

                if (this.seconds > 0.5)
                {
                    this.label.IsCursorShown = false;
                }
                else
                {
                    this.label.IsCursorShown = true;
                }

                if (this.seconds > 1)
                {
                    this.seconds = 0;
                }
            }

            base.Update(gameTime);
        }
Esempio n. 2
0
 /// <summary>
 /// Close listbox when it loses focus.
 /// </summary>
 protected void OnButtonLoseFocus()
 {
     // Only close if not listbox
     if (GUIManager.GetFocus() != this.listBox)
     {
         CloseListBox();
     }
 }
Esempio n. 3
0
        /// <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++;
                }
            }
        }