Пример #1
0
 private void Update()
 {
     if (_Pressed)
     {
         OnPress?.Invoke();
     }
 }
Пример #2
0
 public void HandleAction(ActionType action)
 {
     if (action == ActionType.Activate)
     {
         OnPress?.Invoke();
     }
 }
Пример #3
0
        private void Update()
        {
            if (IsTripleTouch)
            {
                OnTripleTouch?.Invoke();
                return;
            }

            if (StaticUtilities.IsPointerOverUIObject())
            {
                return;
            }

            var inputPosition = Input.mousePosition;

            if (IsPressed)
            {
                OnPress?.Invoke(inputPosition);
            }

            if (IsDrag)
            {
                OnDrag?.Invoke(inputPosition);
            }

            if (IsReleased)
            {
                OnRelease?.Invoke();
            }
        }
Пример #4
0
        protected virtual void Update()
        {
            Touch[] touches = UnityEngine.Input.touches;
            if (touches.Length <= _index)
            {
                return;
            }

            Touch touch = touches[_index];

            if (touch.phase == TouchPhase.Began)
            {
                _currentTouchID = touch.fingerId;
                OnDown?.Invoke(createArg(ButtonState.Down));
            }
            else if (touch.phase == TouchPhase.Canceled || touch.phase == TouchPhase.Ended)
            {
                _currentTouchID = int.MinValue;
                OnReleased?.Invoke(createArg(ButtonState.Released));
            }
            else if (touch.phase == TouchPhase.Moved || touch.phase == TouchPhase.Stationary)
            {
                if (_currentTouchID != touch.fingerId)
                {
                    throw new ArgumentException("The touch iD change before entering Canceled or Ended state!");
                }
                OnPress?.Invoke(createArg(ButtonState.Pressed));
            }
        }
Пример #5
0
 public override void Init()
 {
     GetButton(ModifierButton).OnRelease += () => {
         if (Blocked || !Pressed)
         {
             return;
         }
         Pressed = false;
         OnRelease?.Invoke();
     };
     GetButton(Button).OnPress += () => {
         if (Blocked || !GetButton(ModifierButton).isActive)
         {
             return;
         }
         Pressed = true;
         OnPress?.Invoke();
     };
     GetButton(Button).OnRelease += () => {
         if (Blocked || !Pressed)
         {
             return;
         }
         if (!GetButton(ModifierButton).isActive)
         {
             return;
         }
         Pressed = false;
         OnRelease?.Invoke();
     };
 }
Пример #6
0
 private void Press(object sender, MoveEventArgs e)
 {
     Pushed = true;
     OnPress?.Invoke(this, Color);
     GateBehavior.SendMessage(GateBehavior.GateMsg.Open, Color);
     pressingButton = sender;
 }
Пример #7
0
        // c'tor
        public ModalDisplay(OnPress OnContinue, OnPress OnBack, OnPress OnExitTutorial)
        {
            this.OnContinue     = OnContinue;
            this.OnBack         = OnBack;
            this.OnExitTutorial = OnExitTutorial;

            // We're rendering the text into a 1024x768 rt and then composing that with
            // the background elements into another 1024x768 rt.  This is then scaled
            // and rendered onto the backbuffer.
            camera            = new PerspectiveUICamera();
            camera.Resolution = new Point(1024, 768);

            {
                GetTexture getTexture = delegate() { return(ButtonTextures.AButton); };
                continueButton = new Button(Strings.Localize("tutorial.continue"), Color.White, getTexture, UI2D.Shared.GetGameFont20);
            }
            {
                GetTexture getTexture = delegate() { return(ButtonTextures.BButton); };
                backButton = new Button(Strings.Localize("tutorial.back"), Color.White, getTexture, UI2D.Shared.GetGameFont20);
            }
            {
                GetTexture getTexture = delegate() { return(ButtonTextures.XButton); };
                exitTutorialButton = new Button(Strings.Localize("tutorial.exitTutorial"), Color.White, getTexture, UI2D.Shared.GetGameFont20);
            }
        }   // end of c'tor
Пример #8
0
 // Start is called before the first frame update
 void Start()
 {
     button.onClick.AddListener(() =>
     {
         OnPress?.Invoke(ItemInfo);
     });
 }
Пример #9
0
        internal static void Init()
        {
            PreUpdate();
            LastPosition = Position;

            App.platform.OnMouseButtonDown += id =>
            {
                down[id]    = true;
                pressed[id] = true;
                OnPress?.Invoke((MouseButton)id);
            };

            App.platform.OnMouseButtonUp += id =>
            {
                down[id]     = false;
                released[id] = true;
                OnRelease?.Invoke((MouseButton)id);
            };

            App.platform.OnMouseScroll += (x, y) =>
            {
                Scroll += new Point2((int)(x / Screen.PixelSize), (int)(y / Screen.PixelSize));
                OnScroll?.Invoke();
            };
        }
Пример #10
0
        public void Update(RenderWindow window)
        {
            bool pressed = Mouse.IsButtonPressed(Mouse.Button.Left);

            Vector2f mousePos = new Vector2f(Mouse.GetPosition(window).X, Mouse.GetPosition(window).Y);

            mousePos -= window.GetView().Size * 0.5f - window.GetView().Center;

            Vector2f delta = mousePos - _background.Position;

            if (Math.Abs(delta.X) < _background.Size.X * 0.5f && Math.Abs(delta.Y) < _background.Size.Y * 0.5f)
            {
                // Hover
                _background.FillColor = pressed ? _pressColor : _hoverColor;

                if (!pressed && _lastFramePressed)
                {
                    OnPress?.Invoke(this, EventArgs.Empty);
                }
            }
            else
            {
                _background.FillColor = _defaultColor;
            }

            _lastFramePressed = pressed;
        }
Пример #11
0
        public virtual void Init()
        {
            var otherButtons = BUTTONS.Where(button => button != Button).ToList();

            otherButtons.ForEach(button => GetButton(button).OnPress += () => { Pressed = false; });

            GetButton(Button).OnPress += () => {
                if (Blocked)
                {
                    return;
                }
                if (otherButtons.Any(id => GetButton(id).isActive))
                {
                    return;
                }
                Pressed = true;
                OnPress?.Invoke();
            };
            GetButton(Button).OnRelease += () => {
                if (Blocked || !Pressed)
                {
                    return;
                }
                if (otherButtons.Any(id => GetButton(id).isActive))
                {
                    return;
                }
                Pressed = false;
                OnRelease?.Invoke();
            };
        }
Пример #12
0
        public override void MouseUp(NSEvent theEvent)
        {
            CGPoint p = theEvent.LocationInWindow;

            ClickArgs.Position = new SKPointI((int)p.X, (int)View.Frame.Height - (int)p.Y);
            OnPress?.Invoke(this, ClickArgs);
        }
Пример #13
0
 public void OnPointerDown(PointerEventData eventData)
 {
     Knob.OnDragBegin(eventData.position);
     _pressPosition = eventData.position;
     _moveDirection = Vector2.zero;
     Knob.gameObject.SetActive(true);
     OnPress?.Invoke();
 }
Пример #14
0
        public void OnPointerDown(PointerEventData eventData)
        {
            offsetPosition = eventData.position - (Vector2)rectTransform.position;
            targetPosition = eventData.position - offsetPosition;

            OnPress.Invoke();

            IsPressing = true;
        }
Пример #15
0
    public void OnPointerClick(PointerEventData pointerEventData)
    {
        if (model.messageType != ChatMessage.Type.PRIVATE)
        {
            return;
        }

        OnPress?.Invoke(model.otherUserId);
    }
Пример #16
0
    public override void Use()
    {
        OnPress.Invoke();

        if (pressedSprite)
        {
            StartCoroutine("VisualizeUse");
        }
    }
Пример #17
0
        public void OnPointerDown(PointerEventData eventData)
        {
            if (!myButton.interactable)
            {
                return;
            }

            myButton.image.sprite = pressedSprite;
            OnPress?.Invoke();
        }
Пример #18
0
        public void KeyUp(int vCode, Keys key)
        {
            if (KeysDown.ContainsKey(vCode))
            {
                KeysDown[vCode].To = DateTime.UtcNow;
                var pressed = KeysDown.ToList();
                KeysDown.Remove(vCode);

                OnPress?.Invoke(pressed.Select(p => p.Key).ToList(), pressed.Select(p => p.Value).ToList());
            }
        }
Пример #19
0
 public void Init()
 {
     CaveInputBinding.Flystick(Instance).GetButton(Button).OnPress += () => {
         Pressed = true;
         OnPress?.Invoke();
     };
     CaveInputBinding.Flystick(Instance).GetButton(Button).OnRelease += () => {
         Pressed = false;
         OnRelease?.Invoke();
     };
 }
Пример #20
0
 private bool Press(int touchId, Vector2 position)
 {
     if (!Pressed && (CheckHit == null || CheckHit(position)))
     {
         Pressed = true;
         TouchId = touchId;
         OnPress?.Invoke(position);
         return(true);
     }
     return(false);
 }
Пример #21
0
 private void _buttonPin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs e)
 {
     if (e.Edge == GpioPinEdge.FallingEdge)
     {
         OnPress?.Invoke(sender, e);
     }
     else
     {
         OnRelease?.Invoke(sender, e);
     }
 }
Пример #22
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.CompareTag("playerShadow"))
     {
         _audioSource.clip = AudioList.Instance.button;
         _audioSource.Play();
         _animator.SetBool("Active", true);
         _boxCollider.enabled = false;
         OnPress.Invoke(_id);
     }
 }
Пример #23
0
    public override void OnPointerDown(PointerEventData eventData)
    {
        if (joystickType != JoystickType.Fixed)
        {
            background.anchoredPosition = ScreenPointToAnchoredPosition(eventData.position);
            background.gameObject.SetActive(true);
        }

        OnPress?.Invoke(eventData);

        base.OnPointerDown(eventData);
    }
Пример #24
0
 public void CheckForInput()
 {
     if (ButtonType == ButtonType.Mouse ? Input.GetMouseButtonDown((int)MouseButton) : Input.GetKeyDown(KeyboardButton))
     {
         Pressed = true;
         OnPress?.Invoke();
     }
     if (ButtonType == ButtonType.Mouse ? Input.GetMouseButtonUp((int)MouseButton) : Input.GetKeyUp(KeyboardButton))
     {
         Pressed = false;
         OnRelease?.Invoke();
     }
 }
Пример #25
0
 public _BackdropTitle(
     Key key = null,
     Animation <float> listenable = null,
     OnPress onPress   = null,
     Widget frontTitle = null,
     Widget backTitle  = null
     ) : base(key: key, listenable: listenable)
 {
     D.assert(frontTitle != null);
     D.assert(backTitle != null);
     this.backTitle  = backTitle;
     this.frontTitle = frontTitle;
     this.onPress    = onPress;
 }
Пример #26
0
        private void Window_MouseButtonPressed(object sender, MouseButtonEventArgs e)
        {
            if (e.Button != Mouse.Button.Left)
            {
                return;
            }

            if (MouseInBounds() && Program.WindowFocused)
            {
                if (OnPress != null)
                {
                    OnPress.Invoke();
                }
            }
        }
Пример #27
0
        private void HandleKeyReleasedHookEvent(KeyboardHookEventArgs args)
        {
            OnHook?.Invoke(args);

            lock (downKeys)
            {
                bool removed = downKeys.Remove(args.KeyCode);

                OnRelease?.Invoke(args);

                if (removed)
                {
                    OnPress?.Invoke(args);
                }
            }
        }
 protected virtual void Update()
 {
     if (UnityEngine.Input.GetKeyDown(_key))
     {
         OnDown?.Invoke(createArg(ButtonState.Down));
     }
     else if (UnityEngine.Input.GetKey(_key))
     {
         _stateDuration += Time.deltaTime;
         OnPress?.Invoke(createArg(ButtonState.Pressed));
     }
     else if (UnityEngine.Input.GetKeyUp(_key))
     {
         _stateDuration += Time.deltaTime;
         OnReleased?.Invoke(createArg(ButtonState.Released));
         _stateDuration = 0;
     }
 }
Пример #29
0
    public void StopUsing()
    {
        if (_isHovered)
        {
            this.Hover();
        }
        else
        {
            this.Default();
        }

        if (debugMode)
        {
            Debug.Log("Slider value: " + this.Value);
        }

        OnPress.Invoke();
    }
Пример #30
0
        public static void UpdateMouse(GameTime gameTime, MouseState mState)
        {
            if (currentCamera == null)
            {
                currentCamera = Repository.GetSelectedCamera();
            }

            if (mState.LeftButton == ButtonState.Pressed)
            {
                // Taking into account the camera position since it is causing issues when the camera is moved.
                var currentMousePosition = mState.Position.ToVector2() + currentCamera.Transform.Position;
                var delta = Vector2.Zero;
                if (!LastMouseClick.Equals(Vector2.Zero))
                {
                    delta = currentMousePosition - LastMouseClick;
                }

                if (!Pressed)
                {
                    OnPress?.Invoke(new PointerEventDataArgs(currentMousePosition, delta));
                    Pressed = true;
                }

                LastMouseClick = currentMousePosition;

                if (delta != Vector2.Zero)
                {
                    OnDrag?.Invoke(new PointerEventDataArgs(currentMousePosition, delta));
                }

                if (LastMouseClick.Equals(Vector2.Zero))
                {
                    LastMouseClick = currentMousePosition;
                }
            }
            else if (Pressed)
            {
                OnRelease?.Invoke(new PointerEventDataArgs(LastMouseClick, Vector2.Zero));
                Pressed = false;

                LastMouseClick = Vector2.Zero;
            }
        }