Ejemplo n.º 1
0
 private void Update()
 {
     if (_Pressed)
     {
         OnPress?.Invoke();
     }
 }
Ejemplo n.º 2
0
 public void HandleAction(ActionType action)
 {
     if (action == ActionType.Activate)
     {
         OnPress?.Invoke();
     }
 }
Ejemplo n.º 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();
            }
        }
Ejemplo n.º 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));
            }
        }
Ejemplo n.º 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();
     };
 }
Ejemplo n.º 6
0
 private void Press(object sender, MoveEventArgs e)
 {
     Pushed = true;
     OnPress?.Invoke(this, Color);
     GateBehavior.SendMessage(GateBehavior.GateMsg.Open, Color);
     pressingButton = sender;
 }
Ejemplo n.º 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
Ejemplo n.º 8
0
 // Start is called before the first frame update
 void Start()
 {
     button.onClick.AddListener(() =>
     {
         OnPress?.Invoke(ItemInfo);
     });
 }
Ejemplo n.º 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();
            };
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 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();
            };
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 13
0
 public void OnPointerDown(PointerEventData eventData)
 {
     Knob.OnDragBegin(eventData.position);
     _pressPosition = eventData.position;
     _moveDirection = Vector2.zero;
     Knob.gameObject.SetActive(true);
     OnPress?.Invoke();
 }
Ejemplo n.º 14
0
        public void OnPointerDown(PointerEventData eventData)
        {
            offsetPosition = eventData.position - (Vector2)rectTransform.position;
            targetPosition = eventData.position - offsetPosition;

            OnPress.Invoke();

            IsPressing = true;
        }
Ejemplo n.º 15
0
    public void OnPointerClick(PointerEventData pointerEventData)
    {
        if (model.messageType != ChatMessage.Type.PRIVATE)
        {
            return;
        }

        OnPress?.Invoke(model.otherUserId);
    }
Ejemplo n.º 16
0
    public override void Use()
    {
        OnPress.Invoke();

        if (pressedSprite)
        {
            StartCoroutine("VisualizeUse");
        }
    }
Ejemplo n.º 17
0
        public void OnPointerDown(PointerEventData eventData)
        {
            if (!myButton.interactable)
            {
                return;
            }

            myButton.image.sprite = pressedSprite;
            OnPress?.Invoke();
        }
Ejemplo n.º 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());
            }
        }
Ejemplo n.º 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();
     };
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 21
0
 private void _buttonPin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs e)
 {
     if (e.Edge == GpioPinEdge.FallingEdge)
     {
         OnPress?.Invoke(sender, e);
     }
     else
     {
         OnRelease?.Invoke(sender, e);
     }
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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);
    }
Ejemplo n.º 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();
     }
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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();
                }
            }
        }
Ejemplo n.º 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;
     }
 }
Ejemplo n.º 29
0
    public void StopUsing()
    {
        if (_isHovered)
        {
            this.Hover();
        }
        else
        {
            this.Default();
        }

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

        OnPress.Invoke();
    }
Ejemplo n.º 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;
            }
        }