public void OnPointerClick()
 {
     if (!Cursor.visible)
     {
         OnClick?.Invoke();
     }
 }
Exemplo n.º 2
0
 public void Draw(Rectangle cursorLocation, bool click)
 {
     if (StaticSprite.Hitbox.Intersects(cursorLocation))
     {
         HoverSprite.Draw();
         Text.Draw();
         if (click)
         {
             OnClick?.Invoke(null, new ButtonEventArgs());
             GameData.Instance.CurrentSkin.Click.Play();
         }
         if (!MouseIsOver)
         {
             MouseIsOver = true;
             OnMouseEnter?.Invoke(null, new ButtonEventArgs());
             GameData.Instance.CurrentSkin.MouseOver.Play();
         }
     }
     else
     {
         MouseIsOver = false;
         StaticSprite.Draw();
         Text.Draw();
     }
 }
Exemplo n.º 3
0
        public void Start()
        {
            BeginTime     = DateTime.Now;
            nextRaiseTime = BeginTime.AddMilliseconds(Target.Delay + Target.Interval);

            OnClick?.Invoke(this, null);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Override to define mouse up behaviour. Fires once per mouse release.
        /// </summary>
        /// <param name="X">X</param>
        /// <param name="Y">Y</param>
        public virtual void MouseUp(float X, float Y)
        {
            //this more or less emulates Windows behaviour
            //you can mousedown, move out and back in again and releasing will click the control
            //otherwise mouseup wastes the click
            if (this.WM.LastClickedControl != null && this.WM.LastClickedControl == this)
            {
                this.Click(X, Y);
                if (this is ITextInput input)
                {
                    this.WM.FocusedText = input;
                }
                else
                {
                    this.WM.FocusedText?.LoseFocus();
                    this.WM.FocusedText = null;
                }
                OnClick?.Invoke(this, new ClickEventArgs((int)X, (int)Y));
            }
            foreach (Control c in this.Controls)
            {
                if (c.CheckCollision(X, Y))
                {
                    c.MouseUp(X - c.X, Y - c.Y);


                    break;
                }
            }
            this.WM.LastClickedControl = null;
        }
Exemplo n.º 5
0
 internal override void HandleOnMouseDown(MouseButtonEventArgs e)
 {
     if (mouseOver)
     {
         OnClick?.Invoke(this, EventArgs.Empty);
     }
 }
Exemplo n.º 6
0
        public bool OnPointerClick(PointerEventData eventData)
        {
            Vector2 localPoint;

            if (RectTransformUtility.ScreenPointToLocalPointInRectangle(rectTransform, eventData.pressPosition, eventData.pressEventCamera, out localPoint))
            {
                if (Vector2.Distance(Vector2.zero, localPoint) <= _pointRadius + _pointSkin)
                {
                    OnClick?.Invoke(this, new EventArgs(eventData, isPointEvent: true));
                }
                else if (Vector2.Distance(localPoint, _outHandlePosition) <= _handleRadius + _handleSkin)
                {
                    OnClick?.Invoke(this, new EventArgs(eventData, isOutHandleEvent: true));
                }
                else if (Vector2.Distance(localPoint, _inHandlePosition) <= _handleRadius + _handleSkin)
                {
                    OnClick?.Invoke(this, new EventArgs(eventData, isInHandleEvent: true));
                }
                else
                {
                    return(!IsEventOutside(eventData));
                }

                return(true);
            }

            return(false);
        }
Exemplo n.º 7
0
 private void ContentPresenter_PointerReleased(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
 {
     OnClick?.Invoke(this, null);
     e.Handled = true;
     GlobalScaleTransform.ScaleX = 1.0;
     GlobalScaleTransform.ScaleY = 1.0;
 }
        public AccordionItemView()
        {
            InitializeComponent();

            Padding = 0;

            AccordionItemButton.Command = new Command(() =>
            {
                if (AccordionItemButton.IsPressed)
                {
                    OpenPanel();
                }
                else
                {
                    ClosePanel();
                }

                OnClick?.Invoke(this, new AccordionItemClickEventArgs(this));
            });

            AccordionItemButton.BackgroundColor       = ButtonBackgroundColor;
            AccordionItemButton.ActiveBackgroundColor = ButtonActiveBackgroundColor;
            AccordionItemButton.Border            = Border;
            AccordionItemButton.BorderColor       = BorderColor;
            AccordionItemButton.ActiveBorderColor = ActiveBorderColor;
            AccordionItemButton.TextColor         = TextColor;
            AccordionItemButton.ActiveTextColor   = ActiveTextColor;
            AccordionItemButton.TextPosition      = TextPosition;
            AccordionItemButton.FontSize          = FontSize;
            AccordionItemButton.LeftImage         = LeftImage;
            AccordionItemButton.ActiveLeftImage   = ActiveLeftImage;
            AccordionItemButton.RightImage        = RightImage;
            AccordionItemButton.ActiveRightImage  = ActiveRightImage;
            AccordionItemButton.InnerPadding      = InnerPadding;
        }
Exemplo n.º 9
0
 private void Start()
 {
     _button.onClick.AddListener(() =>
     {
         OnClick?.Invoke();
     });
 }
Exemplo n.º 10
0
        protected internal override void Update()
        {
            // if locked => FPS view => ignore.
            if (Input.LockMode == CursorLockModes.Lock)
            {
                Hovered = false;
            }

            if (Locked)
            {
                return;
            }

            Vector2I mpos = Input.MousePosition;
            Vector2I bpos = (Vector2I)this.Background.GlobalPosition.XY;
            Vector2I bsca = (Vector2I)this.Background.GlobalScale.XY / 2;

            //AABB with mouse point
            bool isHovered =
                (mpos.X > bpos.X - bsca.X) && (mpos.X < bpos.X + bsca.X) &&  //within X
                (mpos.Y > bpos.Y - bsca.Y) && (mpos.Y < bpos.Y + bsca.Y);    //within Y

            Hovered = isHovered;

            if (Hovered && Input.IsPressing(Keys.MouseLeftButton))
            {
                OnClick?.Invoke();
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// 点击选中日期
        /// </summary>
        /// <param name="day"></param>
        private void PanelDay_OnClick(string day)
        {
            foreach (var control in flpControls.Controls)
            {
                if (control is PanelDay)
                {
                    PanelDay panelDay = control as PanelDay;
                    if (panelDay.Day == day)
                    {
                        panelDay.IsSelect = true;
                        if (!panelDay.IsSet)
                        {
                            panelDay.SetValue();
                        }
                    }
                    else if (panelDay.IsSelect == true)
                    {
                        panelDay.IsSelect = false;
                        if (!panelDay.IsSet)
                        {
                            panelDay.SetValue();
                        }
                    }
                }
            }

            string year  = txtYear.Text.Trim();
            string month = txtMonth.Text.Trim();

            DateTime date = new DateTime(int.Parse(year), int.Parse(month), int.Parse(day));

            //OnClick?.Invoke(string.Format("{0}年{1}月{2}日", year, month, day));
            OnClick?.Invoke(date);
        }
Exemplo n.º 12
0
 private void Start()
 {
     _btnCountry.onClick.AddListener(() =>
     {
         OnClick?.Invoke(_diallingCode, _countryName);
     });
 }
Exemplo n.º 13
0
 public void Tick()
 {
     if (ImGui.Button($"{Name}###{Text}"))
     {
         OnClick?.Invoke();
     }
 }
Exemplo n.º 14
0
        public override void Update(GameTime gameTime, MouseState mouseState, KeyboardState keyboardState)
        {
            if (!Enabled)
            {
                return;
            }

            if (drawArea.Contains(mouseState.Position))
            {
                if (mouseState.LeftButton == ButtonState.Pressed)
                {
                    state = UIButtonState.CLICKED;
                }

                if (mouseState.LeftButton == ButtonState.Pressed && oldState.LeftButton != ButtonState.Pressed)
                {
                    OnClick?.Invoke(this, null);
                }
                else if (mouseState.LeftButton != ButtonState.Pressed)
                {
                    state = UIButtonState.HOVER;
                }
            }
            else
            {
                state = UIButtonState.IDLE;
            }

            oldState = mouseState;
        }
Exemplo n.º 15
0
 public void OnPointerClick(PointerEventData eventData)
 {
     if (eventData.button == PointerEventData.InputButton.Left)
     {
         OnClick?.Invoke(this);
     }
 }
Exemplo n.º 16
0
        public ImageGridEntry(string name, byte[] image)
        {
            Name  = name;
            Image = image;

            ClickRouter = (sender, args) => { OnClick?.Invoke(this, args); };
        }
Exemplo n.º 17
0
 public override void Update(GameTime gameTime)
 {
     if (Selected)
     {
         if (inputManager.ActionWasJustPressed("MoveLeft"))
         {
             if (volume > 0.0f)
             {
                 volume -= 0.1f;
                 volume  = (float)Math.Round(volume, 1);
             }
             OnClick?.Invoke(this, new EventArgs());
         }
         else if (inputManager.ActionWasJustPressed("MoveRight"))
         {
             if (volume < 1.0f)
             {
                 volume += 0.1f;
                 volume  = (float)Math.Round(volume, 1);
             }
             OnClick?.Invoke(this, new EventArgs());
         }
         if (volume < 0.1f)
         {
             volume = 0.0f;
         }
         if (volume > 1.0f)
         {
             volume = 1.0f;
         }
         if (inputManager.ActionWasJustPressed("Accept"))
         {
         }
     }
 }
Exemplo n.º 18
0
 void HandleRightClick(MouseEventArgs args)
 {
     if (args.Button == 2)
     {
         OnClick?.Invoke(BaseBidiButton.ClickType.RIGHT_CLICK);
     }
 }
Exemplo n.º 19
0
        private void OnClickAction(SteamVR_Action_In actionIn)
        {
            if (clickAction.GetStateDown(inputSource))
            {
                return;
            }
            var selectedGo = EventSystem.current.currentSelectedGameObject;

            if (selectedGo == null)
            {
                return;
            }

            var selectable = selectedGo.GetComponent <Selectable>();

            if (selectable != null)
            {
                // Execute click on selectable
                ExecuteEvents.Execute(selectable.gameObject, new BaseEventData(EventSystem.current),
                                      ExecuteEvents.submitHandler);
                OnClick?.Invoke();
            }

            var controllerUi = GetComponentInParent <ControllerUI>();

            if (controllerUi != null && hideOnClick.Contains(selectable))
            {
                controllerUi.Hide();
            }
        }
Exemplo n.º 20
0
 public virtual void CursorPressed(Vector2 cursorPos)
 {
     if (IsCursorOver(cursorPos))
     {
         OnClick?.Invoke(this);
     }
 }
Exemplo n.º 21
0
        public void Update(GameWindow window)
        {
            //Console.WriteLine("updated");
            MouseInput.Update();
            Vector2     MousePos  = MouseInput.GetMousePos();
            ButtonState MouseLeft = MouseInput.GetMouseLeftButton();

            if (MousePos.X > GetPosition().X + window.Width / 2f - GetSize().X / 2f &&
                MousePos.X < GetPosition().X + window.Width / 2f + GetSize().X / 2f &&
                MousePos.Y < -GetPosition().Y + window.Height / 2f + GetSize().Y / 2f &&
                MousePos.Y > -GetPosition().Y + window.Height / 2f - GetSize().Y / 2f)
            {
                _sprite.Colour = new Colour(0.5f, 0.5f, 0.5f);

                if (MouseLeft == ButtonState.Pressed && i == 0)
                {
                    i = 1;
                    OnClick?.Invoke(this, EventArgs.Empty);
                }
                if (MouseLeft == ButtonState.Released)
                {
                    i = 0;
                }
            }
            else
            {
                _sprite.Colour = new Colour(1.0f, 1.0f, 1.0f);
            }
        }
Exemplo n.º 22
0
        public override void Update(float deltaTime)
        {
            currentMouse = Mouse.GetState();

            var mouseRect = new Rectangle(
                currentMouse.X,
                currentMouse.Y,
                1,
                1
                );

            isHovering = false;

            Clicked = false;
            Pressed = false;

            if (mouseRect.Intersects(Rectangle))
            {
                isHovering = true;

                if (currentMouse.LeftButton == ButtonState.Pressed)
                {
                    Pressed = true;
                }

                if (currentMouse.LeftButton == ButtonState.Released && previousMouse.LeftButton == ButtonState.Pressed)
                {
                    Clicked = true;
                    OnClick?.Invoke(this, new EventArgs());
                }
            }

            previousMouse = currentMouse;
        }
Exemplo n.º 23
0
 private void OnMouseUpAsButton()
 {
     if (!isDisabled)
     {
         OnClick?.Invoke(this, new EventArgs());
     }
 }
Exemplo n.º 24
0
        public override void ParseData(string command)
        {
            var jObject = JObject.Parse(command);

            if (jObject["status"] != null)
            {
                Status = jObject["status"].ToString();

                if (Status == "click")
                {
                    OnClick?.Invoke(this, EventArgs.Empty);
                }

                if (Status == "double_click")
                {
                    OnDoubleClick?.Invoke(this, EventArgs.Empty);
                }

                if (Status == "long_click_press")
                {
                    OnLongPress?.Invoke(this, EventArgs.Empty);
                }
            }

            if (jObject["voltage"] != null && float.TryParse(jObject["voltage"].ToString(), out float v))
            {
                Voltage = v / 1000;
            }
        }
Exemplo n.º 25
0
 private void tempOnClick(UnityEngine.EventSystems.PointerEventData eventData)
 {
     if (eventData.button == UnityEngine.EventSystems.PointerEventData.InputButton.Right)
     {
         onRightClick?.Invoke(gameObject);
     }
     else if (eventData.button == UnityEngine.EventSystems.PointerEventData.InputButton.Left)
     {
         if (_doubleClickCoroutine == null)
         {
             OnClick?.Invoke();
             OnClickWithObj?.Invoke(gameObject);
         }
         else
         {
             //存在双击
             if (_isFirstClick)
             {
                 _onDoubleClick?.Invoke(gameObject);
                 _isFirstClick = false;
                 _tempTime     = 0;
             }
             else
             {
                 _isFirstClick = true;
                 _tempTime     = 0;
             }
         }
     }
 }
Exemplo n.º 26
0
        protected override IWidget Create(ButtonState state, BuildContext context)
        {
            var input = UserInputManager.From(context.State);

            state.OnEnter = OnClick;

            var decorated = Decoration != null?Decoration(state, Child) : Child;

            var evw = new EventWidget(decorated)
            {
                Events = new AreaEventHandler()
                {
                    OnMouseClick = (ev) =>
                    {
                        if (state.IsEnabled)
                        {
                            input.Focus(state);
                            OnClick?.Invoke(new ButtonEvent()
                            {
                                MouseButtonEvent = ev
                            });
                        }
                    },
                    OnMouseHoverChange = (m, s) =>
                    {
                        state.IsChanged = true;
                        state.IsHovered = s;
                    },
                }
            };

            return(evw);
        }
Exemplo n.º 27
0
    // public void OnPointerUp(PointerEventData eventData)
    // {
    //  if(Time.time - downTime < ClickTime)
    //      OnClick?.Invoke(eventData);
    // }
    //
    // public void OnPointerDown(PointerEventData eventData)
    // {
    //  downTime = Time.time;
    // }

    public void OnPointerClick(PointerEventData eventData)
    {
        if ((eventData.pressPosition - eventData.position).sqrMagnitude < DragDistance)
        {
            OnClick?.Invoke(eventData);
        }
    }
Exemplo n.º 28
0
 public void Click()
 {
     if (IsMouseOver && IsClickable)
     {
         OnClick?.Invoke(this);
     }
 }
Exemplo n.º 29
0
 public void CheckClick(Vector2 mouse)
 {
     if (CheckHover(mouse))
     {
         OnClick?.Invoke();
     }
 }
        private void onPointerButtonInputUp(PointerButtonInputEventArgs args)
        {
            PointerInputEventArgs pointerInput = _pointerInputRegistry.GetPointerInput(_parameter.PointerParameter.PointerButtonIndex);

            if (args.Duration > _parameter.InputParameter.MaxClickDuration ||
                (pointerInput.ScreenPosition - _pointerInputOnClickStart.ScreenPosition).magnitude > _parameter.InputParameter.MaxPointerDelta)
            {
                clean();
                return;
            }

            List <PointerRaycastHit> hits = new List <PointerRaycastHit>();

            foreach (PointerRaycastHit hit in pointerInput.RaycastHits)
            {
                foreach (PointerRaycastHit clickStartHit in _pointerInputOnClickStart.RaycastHits)
                {
                    if (hit.Obj != clickStartHit.Obj)
                    {
                        continue;
                    }
                    hits.Add(clickStartHit);
                }
            }

            OnClick?.Invoke(new ClickInputEventArgs(hits.ToArray(), _pointerInputOnClickStart));
            clean();
        }