public void Update(GameTime gameTime, KeyboardState keyboardState, MouseState mouseState, MouseState prevMouseState) { if (isBeingClicked) { var progress = Math.Clamp((mouseState.Position.X - RectOnScreen.Left) / Size.X, 0, 1); var value = Min + (Max - Min) * progress; if (mouseState.LeftButton == ButtonState.Released) { OnRelease?.Invoke(value); isBeingClicked = false; } else if (progress != CurrentProgress) { OnChange?.Invoke(value); } CurrentProgress = progress; CurrentValue = value; } if (mouseState.LeftButton == ButtonState.Pressed && RectOnScreen.Contains(mouseState.Position)) { if (prevMouseState.LeftButton == ButtonState.Released) { isBeingClicked = true; } } }
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(); } }
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(); }; }
/// <summary> /// 释放 /// </summary> public virtual void OnDistanceRelesae(DistanceInteraction distanceInteraction) { if (OnRelease != null) { OnRelease.Invoke(distanceInteraction); } }
private void HandleInput() { if (Input.GetMouseButtonDown(0)) { isGrappling = true; } if (Input.GetMouseButton(0)) { if (isGrappling) { isGrappling = false; var clickResult = OnClicked?.Invoke(player.transform.position); if (clickResult.HasValue) { var joint = clickResult.Value.Item1; joint.connectedBody = player; OnAttach?.Invoke(joint.transform.position); TravelAmount = clickResult.Value.Item2 + 1; OnScore?.Invoke(TravelAmount); } } } if (Input.GetMouseButtonUp(0)) { OnRelease?.Invoke(); } }
protected void InvokeOnRelease(T item) { if (OnRelease != null) { OnRelease.Invoke(item); } }
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(); }; }
private void CheckSwipeEditor() { if (Input.GetMouseButtonDown(0)) //pressed { startPos = Input.mousePosition; holdTime = 0; } else if (Input.GetMouseButton(0)) //held { holdTime += Time.deltaTime; } else if (Input.GetMouseButtonUp(0)) //de-pressed { Vector2 endPos = Input.mousePosition; Vector2 deltaPos = endPos - startPos; //Debug.Log("" + (deltaPos.magnitude > swipeDistanceThreshold) + " and " + (holdTime < swipeTimeThreshold)); if (deltaPos.magnitude > swipeDistanceThreshold && holdTime < swipeTimeThreshold) { OnSwipe?.Invoke(deltaPos, endPos); } else { OnRelease?.Invoke(); } } }
/// <summary> /// 释放扩展 /// </summary> /// <param name="extend">扩展实现</param> private void InternalRelease(TInterface extend) { OnRelease?.Invoke(extend); var dispose = extend as IDisposable; dispose?.Dispose(); }
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(); }; }
// Update is called once per frame void Update() { if (Input.touchCount > 0) { _touch = Input.GetTouch(0); _touchTimer += Time.deltaTime; switch (_touch.phase) { case TouchPhase.Ended: if (_touch.tapCount >= 2) { StopAllCoroutines(); if (OnDoubleClick != null) { OnDoubleClick.Invoke(_touch); Debug.Log("Working"); } } else if (_touchTimer < LongPressThreshold) { StartCoroutine(CheckSingleClick()); } else if (_touchTimer > LongPressThreshold) { StopAllCoroutines(); OnRelease.Invoke(_touch); } break; case TouchPhase.Moved: if (_touchTimer > LongPressThreshold) { if (OnLongPressing != null) { OnLongPressing.Invoke(_touch); } } break; case TouchPhase.Stationary: if (_touchTimer > LongPressThreshold) { if (OnLongPressing != null) { OnLongPressing.Invoke(_touch); } } break; default: break; } } else { _touchTimer = 0; } }
private bool Release(int touchId, Vector2 position) { if (Pressed && TouchId == touchId) { OnRelease?.Invoke(position); Pressed = false; return(true); } return(false); }
private void _buttonPin_ValueChanged(GpioPin sender, GpioPinValueChangedEventArgs e) { if (e.Edge == GpioPinEdge.FallingEdge) { OnPress?.Invoke(sender, e); } else { OnRelease?.Invoke(sender, e); } }
public override void OnPointerUp(PointerEventData eventData) { if (joystickType != JoystickType.Fixed) { background.gameObject.SetActive(false); } OnRelease?.Invoke(eventData); base.OnPointerUp(eventData); }
public virtual void Release() { if (currentObject == null) { return; } OnRelease.Invoke(currentObject.gameObject); currentObject.Release(this); currentObject = null; }
public void Init() { CaveInputBinding.Flystick(Instance).GetButton(Button).OnPress += () => { Pressed = true; OnPress?.Invoke(); }; CaveInputBinding.Flystick(Instance).GetButton(Button).OnRelease += () => { Pressed = false; OnRelease?.Invoke(); }; }
public void PointerUp() { if (lastPointerDownTime != null) { OnClick?.Invoke(); lastPointerDownTime = null; } else { OnRelease?.Invoke(); } }
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(); } }
public void OnPoolRelease() { if (lifecycleHandlers != null) { for (var i = 0; i < lifecycleHandlers.Length; i++) { var handler = lifecycleHandlers[i]; handler.OnPoolRelease(); } } OnRelease?.Invoke(); }
/// <summary> /// Release rocker. /// </summary> protected virtual void OnMouseUp() { if (!isEnabled) { return; } if (revertSpeed > 0) { InvokeRepeating("Revert", 0, Time.fixedDeltaTime); } OnRelease.Invoke(); }
private void _ReleaseSlider() { Cursor.Margin = InitialCursorMargin; DynamicBar.X2 = DynamicBar.X1; CurrentValueText.Text = ""; OnRelease?.Invoke(this, new OnReleaseArgs() { Value = (int)CurrentValue }); CurrentValue = 0; ToolTipFlyout.Hide(); }
private void Update() { if (Input.GetMouseButtonUp(0) && IsPressing) // "OnMouseUp()" is unreliable. { if (resetOnRelease) { transform.position = startWorldPosition; } OnRelease.Invoke(); IsPressing = false; } }
private void OnMouseButton(MouseButton button, InputAction action, KeyModifiers mods) { if (button == MouseButton.Left && Hovered) { if (action == InputAction.Press) { OnClick?.Invoke(this, null); } else if (action == InputAction.Release) { OnRelease?.Invoke(this, null); } } }
public void Release(Vector2 input) { if (joint != null) { joint.connectedBody = null; joint.enabled = false; if (input == Vector2.zero) { motor.velocity = Vector3.zero; } OnRelease?.Invoke(); Destroy(ActiveGrab, .1f); } }
public void Release(VRHand hand) { if (Holder != hand) { return; } TrackHolder(Holder.position, Holder.rotation); rb.velocity = SmoothVelocity; rb.angularVelocity = SmoothSpin; OnRelease.Invoke(hand.gameObject); Holder = null; }
private void HandleKeyReleasedHookEvent(KeyboardHookEventArgs args) { OnHook?.Invoke(args); lock (downKeys) { bool removed = downKeys.Remove(args.KeyCode); OnRelease?.Invoke(args); if (removed) { OnPress?.Invoke(args); } } }
public override void OnPointerUp(PointerEventData eventData) { if (_timer <= DoubleTapTreshold) { _indeterminacy = true; } if (_timer > DoubleTapTreshold) { _toTick = false; OnRelease?.Invoke(_inputVector, _timer); //Debug.LogWarning("LONG RELEASe " + _timer); _timer = 0; } _inputVector = Vector2.zero; Handle.anchoredPosition = Vector2.zero; }
private void HandleKeyReleasedHookEvent(MouseHookEventArgs args) { OnHook?.Invoke(args); lock (downButtons) { bool removed = downButtons.Remove(args.Button); OnRelease?.Invoke(args); if (removed) { OnClick?.Invoke(args); } } }
private void FlipStatus() { status = !status; if (status) { OnTrigger?.Invoke(); } else if (!status) { OnRelease?.Invoke(); } if (MouseButton == EMouseButton.WheelDown || MouseButton == EMouseButton.WheelUp) { status = false; } }
/// <summary> /// Response mouse left button up. /// </summary> protected virtual void OnMouseUp() { if (!isEnabled) { return; } OnRelease.Invoke(); if (!adsorbent || adsorbableAngles.Length == 0) { return; } Angle = GetAdsorbentAngle(Angle, adsorbableAngles); Rotate(Angle); OnAdsorbent.Invoke(); }