Ejemplo n.º 1
0
 /// <summary>Called when a mouse button has been released again</summary>
 /// <param name="button">Index of the button that has been released</param>
 protected override void OnMouseReleased(S33M3CoreComponents.GUI.Nuclex.Input.MouseButtons button)
 {
     if (button == S33M3CoreComponents.GUI.Nuclex.Input.MouseButtons.Left)
     {
         this.beingDragged = false;
     }
 }
Ejemplo n.º 2
0
 /// <summary>Called when a mouse button has been released again</summary>
 /// <param name="button">Index of the button that has been released</param>
 protected override void OnMouseReleased(S33M3CoreComponents.GUI.Nuclex.Input.MouseButtons button)
 {
     if (button == MouseButtons.Left)
     {
         this.pressedDown = false;
     }
 }
Ejemplo n.º 3
0
 /// <summary>Called when a mouse button has been pressed down</summary>
 /// <param name="button">Index of the button that has been pressed</param>
 protected override void OnMousePressed(S33M3CoreComponents.GUI.Nuclex.Input.MouseButtons button)
 {
     if (button == S33M3CoreComponents.GUI.Nuclex.Input.MouseButtons.Left)
     {
         this.beingDragged = this.enableDragging;
     }
 }
Ejemplo n.º 4
0
        /// <summary>Called when a mouse button has been pressed down</summary>
        /// <param name="button">Index of the button that has been pressed</param>
        /// <returns>Whether the control has processed the mouse press</returns>
        internal bool ProcessMousePress(S33M3CoreComponents.GUI.Nuclex.Input.MouseButtons button)
        {
            // We remember the control the mouse was pressed over and won't replace it for
            // as long as the mouse is being held down. This ensures the mouse release
            // notification is always delivered to a control, even if the mouse is released
            // after moving it away from the control.
            if (this.activatedControl == null)
            {
                this.activatedControl = this.mouseOverControl;


                // Add the buttons to the list of mouse buttons being held down. This is used
                // to track when we should clear the mouse-over control again.
                this.heldMouseButtons |= button;

                // If we received an initial mouse press outside of our control area,
                // someone is feeding us notifications we shouldn't be receiving. The best
                // thing we can do is ignore this notification. This is a normal situation
                // for the top level control which does the input filtering.
                if (this.activatedControl == null)
                {
                    return(false);
                }

                // If we're a control that can appear on top of or below our siblings in
                // the z order, bring us into foreground since the user just clicked on us.
                if (this.activatedControl != this)
                {
                    if (this.activatedControl.affectsOrdering)
                    {
                        this.children.MoveToStart(this.children.IndexOf(this.activatedControl));
                    }
                }
            }


            // If the mouse is over another control, pass on the mouse press.
            if (this.activatedControl != this)
            {
                return(this.activatedControl.ProcessMousePress(button));
            }
            else
            { // Otherwise, the mouse press applies to us
                // If this control can take the input focus, make it the focused control
                if (this.screen != null)
                {
                    IFocusable focusable = this as IFocusable;
                    if ((focusable != null) && (focusable.CanGetFocus))
                    {
                        this.screen.FocusedControl = this;
                    }
                }

                // Deliver the notification to the control deriving from us
                OnMousePressed(button);
                return(true);
            }
        }
Ejemplo n.º 5
0
 /// <summary>Called when a mouse button has been pressed down</summary>
 /// <param name="button">Index of the button that has been pressed</param>
 protected override void OnMousePressed(S33M3CoreComponents.GUI.Nuclex.Input.MouseButtons button)
 {
     if (this.Enabled)
     {
         if (button == S33M3CoreComponents.GUI.Nuclex.Input.MouseButtons.Left)
         {
             this.pressedDownByMouse = true;
         }
     }
 }
Ejemplo n.º 6
0
        /// <summary>Called when a mouse button has been pressed down</summary>
        /// <param name="button">Index of the button that has been pressed</param>
        protected override void OnMousePressed(S33M3CoreComponents.GUI.Nuclex.Input.MouseButtons button)
        {
            if (button == MouseButtons.Left)
            {
                RectangleF thumbRegion = GetThumbRegion();
                if (thumbRegion.Contains(this.pickupX, this.pickupY))
                {
                    this.pressedDown = true;

                    this.pickupX -= thumbRegion.Left;
                    this.pickupY -= thumbRegion.Top;
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>Called when a mouse button has been released again</summary>
        /// <param name="button">Index of the button that has been released</param>
        public void InjectMouseRelease(MouseButtons button)
        {
            heldMouseButtons &= ~button;

            // If a control signed responsible for the earlier mouse press, it will now
            // receive the release notification.
            if (activatedControl != null)
            {
                activatedControl.ProcessMouseRelease(button);
            }

            // Reset the activated control if the user has released all buttons on all
            // input devices.
            if (!anyKeysOrButtonsPressed)
            {
                activatedControl = null;
            }
        }
Ejemplo n.º 8
0
        /// <summary>Called when a mouse button has been pressed down</summary>
        /// <param name="button">Index of the button that has been pressed</param>
        public void InjectMousePress(MouseButtons button)
        {
            HideToolTip();

            heldMouseButtons |= button;

            // If a control is activated, it will receive any input notifications
            if (activatedControl != null)
            {
                activatedControl.ProcessMousePress(button);
                return;
            }

            // No control was activated, so the desktop control becomes activated and
            // is responsible for routing the input to the control under the mouse.
            activatedControl = desktopControl;
            desktopControl.ProcessMousePress(button);
        }
Ejemplo n.º 9
0
        /// <summary>Called when a mouse button has been released again</summary>
        /// <param name="button">Index of the button that has been released</param>
        protected override void OnMouseReleased(S33M3CoreComponents.GUI.Nuclex.Input.MouseButtons button)
        {
            if (button == S33M3CoreComponents.GUI.Nuclex.Input.MouseButtons.Left)
            {
                this.pressedDownByMouse = false;

                // Only trigger the pressed event if the mouse was released over the control.
                // The user can move the mouse cursor away from the control while still holding
                // the mouse button down to do the well-known last-second-abort.
                if (this.mouseHovering && this.Enabled)
                {
                    // If this was the final input device holding down the control, meaning it's
                    // not depressed any longer, this counts as a click and we trigger
                    // the notification!
                    if (!Depressed)
                    {
                        OnPressed();
                    }
                }
            }
        }
Ejemplo n.º 10
0
 /// <summary>Called when a mouse button has been pressed down</summary>
 /// <param name="button">Index of the button that has been pressed</param>
 protected override void OnMousePressed(S33M3CoreComponents.GUI.Nuclex.Input.MouseButtons button)
 {
     if (button == S33M3CoreComponents.GUI.Nuclex.Input.MouseButtons.Left)
     {
         // If the renderer was so nice to provide an OpeningLocator for us,
         // we can locate exactly which opening was closest to the position
         // the user has clicked at and place the caret accordingly
         if (this.OpeningLocator != null)
         {
             RectangleF absoluteBounds   = GetAbsoluteBounds();
             Vector2    absolutePosition = new Vector2(
                 absoluteBounds.X + this.mouseX,
                 absoluteBounds.Y + this.mouseY
                 );
             this.caretPosition = this.OpeningLocator.GetClosestOpening(ref absoluteBounds, Text, ref absolutePosition);
         }
         else
         { // Nope, our renderer is being secretive
             moveCaretToEnd();
         }
     }
 }
Ejemplo n.º 11
0
        /// <summary>Called when a mouse button has been released again</summary>
        /// <param name="button">Index of the button that has been released</param>
        internal void ProcessMouseRelease(S33M3CoreComponents.GUI.Nuclex.Input.MouseButtons button)
        {
            // When the mouse is clicked on game window's border and the user drags it
            // into the GUI area, we will get a rogue mouse release message without
            // the related mouse press. We ignore such rogue mouse release messages.
            if ((this.heldMouseButtons & button) != button)
            {
                return;
            }

            //// If we receive a release, we must have a control on which the mouse
            //// was pressed (possibly even ourselves)
            //Debug.Assert(
            //  this.activatedControl != null,
            //  "ProcessMouseRelease() had no control the mouse was pressed on",
            //  "ProcessMouseRelease() was called on a control instance, but the control " +
            //  "did not register a prior mouse press over itself or any of its child controls"
            //);

            // Remove the button from the list of mouse buttons being held down. This
            // allows us to see when we can clear the mouse-press control.
            this.heldMouseButtons &= ~button;

            // If the mouse was held over one of our childs, pass on the notification
            if (activatedControl != null && this.activatedControl != this)
            {
                this.activatedControl.ProcessMouseRelease(button);
            }
            else
            {
                OnMouseReleased(button);
            }

            // If no more mouse buttons are being held down, clear the mouse-press control
            if (!anyKeysOrButtonsPressed)
            {
                this.activatedControl = null;
            }
        }
Ejemplo n.º 12
0
 /// <summary>Called when a mouse button has been released again</summary>
 /// <param name="button">Index of the button that has been released</param>
 protected virtual void OnMouseReleased(S33M3CoreComponents.GUI.Nuclex.Input.MouseButtons button)
 {
     OnClicked();
 }
Ejemplo n.º 13
0
 /// <summary>Called when a mouse button has been pressed down</summary>
 /// <param name="button">Index of the button that has been pressed</param>
 /// <returns>Whether the control has processed the mouse press</returns>
 /// <remarks>
 ///   If this method states that a mouse press is processed by returning
 ///   true, that means the control did something with it and the mouse press
 ///   should not be acted upon by any other listener.
 /// </remarks>
 protected virtual void OnMousePressed(S33M3CoreComponents.GUI.Nuclex.Input.MouseButtons button)
 {
 }