Esempio n. 1
0
 private void DoMouseDown(UIElement element, Vector2 mousePosition, UIMouseButton button)
 {
     if (button == UIMouseButton.Left)
     {
         buttonDown = true;
     }
 }
Esempio n. 2
0
 private KeyCode ButtonToKeycode(UIMouseButton button)
 {
     if (button == UIMouseButton.Left)
     {
         return(KeyCode.Mouse0);
     }
     if (button == UIMouseButton.Right)
     {
         return(KeyCode.Mouse1);
     }
     if (button == UIMouseButton.Middle)
     {
         return(KeyCode.Mouse2);
     }
     if (button == UIMouseButton.Special0)
     {
         return(KeyCode.Mouse3);
     }
     if (button == UIMouseButton.Special1)
     {
         return(KeyCode.Mouse4);
     }
     if (button == UIMouseButton.Special2)
     {
         return(KeyCode.Mouse5);
     }
     if (button == UIMouseButton.Special3)
     {
         return(KeyCode.Mouse6);
     }
     return(KeyCode.None);
 }
Esempio n. 3
0
 /// <summary>
 /// Override this function to implement behavior to respond to mouse and touch clicks at a specific location
 /// </summary>
 /// <param name="position"></param>
 /// <param name="player"></param>
 /// <param name="button"></param>
 public virtual void ClickAt(Vector2 position, UIMouseButton button)
 {
     if (CanUse(0) && OnClick != null)
     {
         OnClick(this, position, button);
     }
 }
Esempio n. 4
0
 private void OnHooked(MySensitiveObject sender, UIMouseButton btn, RCIntVector hookPos)
 {
     if (btn == UIMouseButton.Left)
     {
         this.hookPosition = hookPos;
     }
 }
Esempio n. 5
0
 static void Postfix(
     ref UIDragDropState ___m_DragState,
     ref UIComponent ___m_ActiveComponent,
     UIMouseButton ___m_ButtonsUp,
     object ___m_DragData)
 {
     try {
         if (!___m_ActiveComponent)  // if during draggin, component dies.
         {
             ___m_DragState       = UIDragDropState.None;
             ___m_ActiveComponent = null;
         }
         if (___m_DragState == UIDragDropState.Dragging &&
             ___m_ButtonsUp.IsFlagSet(UIMouseButton.Right))
         {
             var p = cUIDragEventParameter.Invoke(new[] {
                 ___m_ActiveComponent,
                 UIDragDropState.Cancelled,
                 ___m_DragData,
                 (Vector2)Input.mousePosition
             });
             GetMethod(typeof(UIComponent), "OnDragEnd")
             .Invoke(___m_ActiveComponent, new object[] { p });
             ___m_DragState       = UIDragDropState.None;
             ___m_ActiveComponent = null;
         }
     } catch (Exception ex) {
         Log.Exception(ex);
     }
 }
Esempio n. 6
0
 public override void OnMouseDown(UIMouseButton b)
 {
     lx    = VInput.MX;
     ly    = VInput.MY;
     State = ButState.Press;
     UISys.Skin().ClickSound();
 }
        private static string TranslationForMouseButton(UIMouseButton button)
        {
            switch (button)
            {
            case UIMouseButton.Left:
                return(Translation.Options.Get("Shortcut:Click"));

            case UIMouseButton.Right:
                return(Translation.Options.Get("Shortcut:RightClick"));

            case UIMouseButton.Middle:
                return(Translation.Options.Get("Shortcut:MiddleClick"));

            case UIMouseButton.Special0:
                return("Special0");

            case UIMouseButton.Special1:
                return("Special1");

            case UIMouseButton.Special2:
                return("Special2");

            case UIMouseButton.Special3:
                return("Special3");

            default:
                throw new ArgumentOutOfRangeException(
                          paramName: nameof(button),
                          actualValue: button,
                          message: "Not supported click type for localization");
            }
        }
Esempio n. 8
0
        private KeyCode ButtonToKeycode(UIMouseButton button)
        {
            switch (button)
            {
            case UIMouseButton.Left:
                return(KeyCode.Mouse0);

            case UIMouseButton.Right:
                return(KeyCode.Mouse1);

            case UIMouseButton.Middle:
                return(KeyCode.Mouse2);

            case UIMouseButton.Special0:
                return(KeyCode.Mouse3);

            case UIMouseButton.Special1:
                return(KeyCode.Mouse4);

            case UIMouseButton.Special2:
                return(KeyCode.Mouse5);

            case UIMouseButton.Special3:
                return(KeyCode.Mouse6);

            default:
                return(KeyCode.None);
            }
        }
Esempio n. 9
0
 public override void ClickAt(Vector2 position, UIMouseButton button)
 {
     if (hoveringLink >= 0 && OnLinkClicked != null)
     {
         OnLinkClicked(this, text[hoveringLink].Reference);
     }
 }
Esempio n. 10
0
 public override void OnMouseDown(UIMouseButton b)
 {
     DraggedX = 0;
     DraggedY = 0;
     dragging = true;
     lx       = VInput.MX;
     ly       = VInput.MY;
 }
Esempio n. 11
0
 private bool IsUnbindableMouseButton(UIMouseButton code)
 {
     if (code != UIMouseButton.Left)
     {
         return(code == UIMouseButton.Right);
     }
     return(true);
 }
Esempio n. 12
0
 public override void OnMouseUp(UIMouseButton b)
 {
     if (Click != null)
     {
         Click();
     }
     State = ButState.Norm;
     Event(new UIEvent(this, EventType.Click));
     lx = 0;
     ly = 0;
 }
Esempio n. 13
0
 public HardcodedMouseShortcut(UIMouseButton button,
                     bool shift,
                     bool ctrl,
                     bool alt,
                     string localizedText) {
     button_ = button;
     shift_ = shift;
     ctrl_ = ctrl;
     alt_ = alt;
     localizedText_ = localizedText;
 }
Esempio n. 14
0
 public override void OnMouseDown(UIMouseButton b)
 {
     DraggedX = 0;
     DraggedY = 0;
     dragging = true;
     lx       = VInput.MX;
     ly       = VInput.MY;
     if (DragEv != null)
     {
         Console.WriteLine("Yep");
     }
 }
Esempio n. 15
0
 private KeyCode ButtonToKeycode(UIMouseButton button)
 {
     return(button switch
     {
         UIMouseButton.Left => KeyCode.Mouse0,
         UIMouseButton.Right => KeyCode.Mouse1,
         UIMouseButton.Middle => KeyCode.Mouse2,
         UIMouseButton.Special0 => KeyCode.Mouse3,
         UIMouseButton.Special1 => KeyCode.Mouse4,
         UIMouseButton.Special2 => KeyCode.Mouse5,
         UIMouseButton.Special3 => KeyCode.Mouse6,
         _ => KeyCode.None,
     });
Esempio n. 16
0
        public override void ClickAt(Vector2 position, UIMouseButton button)
        {
            base.ClickAt(position, button);

            /*float rel = 0;
             * if (sliderOrientation == SliderOrientation.Horizontal)
             * {
             *  rel = (position.X / (rect.HalfSize.X - HandleWidth * 0.5f)) * 0.5f + 0.5f;
             * }
             * else
             * {
             *  rel = (position.Y / (rect.HalfSize.Y - HandleHeight * 0.5f)) * -0.5f + 0.5f;
             * }
             * rel = MathHelper.Clamp(rel, 0, 1);
             * SetValue(minValue + (maxValue - minValue) * rel);*/
        }
Esempio n. 17
0
 private void DoMouseMove(UIElement element, Vector2 mousePosition, UIMouseButton button)
 {
     if (buttonDown)
     {
         Vector2 position = mousePosition - this.Position;
         float   rel      = 0;
         if (sliderOrientation == SliderOrientation.Horizontal)
         {
             rel = (position.X / (rect.HalfSize.X - HandleWidth * 0.5f)) * 0.5f + 0.5f;
         }
         else
         {
             rel = (position.Y / (rect.HalfSize.Y - HandleHeight * 0.5f)) * -0.5f + 0.5f;
         }
         rel = MathHelper.Clamp(rel, 0, 1);
         SetValue(minValue + (maxValue - minValue) * rel);
     }
 }
Esempio n. 18
0
        private void DoMouseMove(UIElement element, Vector2 mousePosition, UIMouseButton button)
        {
            this.hoveringLink = -1;
            mousePosition    -= this.Position;
            mousePosition    += (this.Shape as OABB).HalfSize;
            mousePosition    /= relativeSize;
            Trace.WriteLine("mp " + mousePosition);

            for (int i = 0; i < text.Count; i++)
            {
                if (text[i].Reference.Length > 0 && mousePosition.X > text[i].Position.X && mousePosition.X <text[i].Position.X + text[i].Size.X &&
                                                                                                             mousePosition.Y> text[i].Position.Y && mousePosition.Y < text[i].Position.Y + text[i].Size.Y)
                {
                    this.hoveringLink = i;
                    return;
                }
            }
        }
Esempio n. 19
0
 public override void OnMouseDown(UIMouseButton b)
 {
     if (subp != null)
     {
         if (subp.WidOpen == true)
         {
             subp.WidOpen = false;
         }
         else
         {
             subp.WidOpen = true;
         }
     }
     else
     {
         if (Action != null)
         {
             Action();
         }
     }
 }
Esempio n. 20
0
        /// <summary>
        /// Called by UIMouseManager.
        /// </summary>
        public void OnButtonDown(RCIntVector absPosition, UIMouseButton whichButton)
        {
            bool raiseDoubleClickEvt = false;

            if (this.activatorButton == UIMouseButton.Undefined)
            {
                this.activatorButton = whichButton;
                this.activeOver      = true;

                if (this.doubleClickButton == UIMouseButton.Undefined)
                {
                    /// Start double-click timer.
                    this.doubleClickButton   = whichButton;
                    this.doubleClickStartPos = absPosition;
                    this.doubleClickTimer    = 0;
                    UIRoot.Instance.GraphicsPlatform.RenderLoop.FrameUpdate += this.OnFrameUpdate;
                }
                else if (this.doubleClickButton == whichButton && this.doubleClickStartPos == absPosition)
                {
                    /// Double-click happened.
                    raiseDoubleClickEvt = true;
                    this.StopDoubleClickTimer();
                }
            }

            if (this.ButtonDown != null)
            {
                UIMouseEventArgs evtArgs = new UIMouseEventArgs(this.targetObject.TransformAbsToLocal(absPosition),
                                                                whichButton);
                this.ButtonDown(this.targetObject, evtArgs);
            }

            if (raiseDoubleClickEvt && this.DoubleClick != null)
            {
                UIMouseEventArgs evtArgs = new UIMouseEventArgs(this.targetObject.TransformAbsToLocal(absPosition),
                                                                whichButton);
                this.DoubleClick(this.targetObject, evtArgs);
            }
        }
Esempio n. 21
0
        /// <summary>
        /// Called by UIMouseManager.
        /// </summary>
        public void OnButtonUp(RCIntVector absPosition, UIMouseButton whichButton)
        {
            bool wasActiveOver = this.activeOver;

            if (this.activatorButton == whichButton)
            {
                this.activatorButton = UIMouseButton.Undefined;
                this.activeOver      = false;
            }

            if (this.ButtonUp != null)
            {
                UIMouseEventArgs evtArgs = new UIMouseEventArgs(this.targetObject.TransformAbsToLocal(absPosition),
                                                                whichButton);
                this.ButtonUp(this.targetObject, evtArgs);
            }

            if (this.Click != null && wasActiveOver)
            {
                UIMouseEventArgs evtArgs = new UIMouseEventArgs(this.targetObject.TransformAbsToLocal(absPosition),
                                                                whichButton);
                this.Click(this.targetObject, evtArgs);
            }
        }
Esempio n. 22
0
        public override void ClickAt(Vector2 position, UIMouseButton button)
        {
            if (hovering != null)
            {
                hovering.ClickAt(position, button);
            }
            else
            {
                switch (ElementOrientation)
                {
                case UIElementOrientation.LeftRight:
                    if (position.X < 0)
                    {
                        Previous();
                    }
                    else
                    {
                        Next();
                    }
                    break;

                case UIElementOrientation.TopDown:
                    if (position.Y < 0)
                    {
                        Previous();
                    }
                    else
                    {
                        Next();
                    }
                    break;
                }
            }

            base.ClickAt(position, button);
        }
Esempio n. 23
0
 public virtual void OnMouseUp(UIMouseButton b)
 {
 }
Esempio n. 24
0
 private bool IsUnbindableMouseButton(UIMouseButton code)
 {
     return(code == UIMouseButton.Left || code == UIMouseButton.Right);
 }
Esempio n. 25
0
 private bool IsUnbindableMouseButton(UIMouseButton code) => code == UIMouseButton.Left || code == UIMouseButton.Right;
Esempio n. 26
0
 private KeyCode ButtonToKeycode(UIMouseButton button) => button switch
 {
Esempio n. 27
0
 public static bool IsUnbindableMouseButton(UIMouseButton code)
 {
     return(code == UIMouseButton.Left || code == UIMouseButton.Right);
 }
Esempio n. 28
0
 private void DoMouseOut(UIElement element, Vector2 mousePosition, UIMouseButton button)
 {
     this.hoveringLink = -1;
 }
Esempio n. 29
0
 public override void OnMouseUp(UIMouseButton b)
 {
     dragging = false;
 }
Esempio n. 30
0
 public virtual void OnMouseDown(UIMouseButton b)
 {
 }