public virtual void Process(JuniperPointerEventData evtData, float pixelDragThresholdSquared, List <KeyCode> keyPresses, bool paused) { if (!paused) { if (!IsDragging) { TestEnterExit(evtData); } EventTarget = ProcessButtons(evtData, pixelDragThresholdSquared, keyPresses); if (evtData.clickCount == -1) { evtData.clickCount = 0; } } LastWorldPoint = evtData.pointerCurrentRaycast.worldPosition; LastSmoothedWorldPoint = SmoothedWorldPoint; LastOrigin = Origin; Probe?.SetCursor( evtData.pointerCurrentRaycast.gameObject != null, AnyButtonPressed, LastWorldPoint, evtData.pointerCurrentRaycast.worldNormal); }
private void TestDrag(JuniperPointerEventData evtData, float pixelDragThresholdSquared) { if (evtData.pointerDrag != null && evtData.IsPointerMoving()) { var wasDragging = evtData.dragging; if (!IsPressed) { evtData.dragging = false; } else if (!evtData.useDragThreshold) { evtData.dragging = true; } else { dragDistance += evtData.delta.sqrMagnitude; evtData.dragging = dragDistance > pixelDragThresholdSquared; } if (evtData.dragging) { if (evtData.pointerPress != null && evtData.pointerPress != evtData.pointerDrag) { ExecuteEvents.Execute(evtData.pointerPress, evtData, ExecuteEvents.pointerUpHandler); InteractionNeeded(Interaction.Released); evtData.eligibleForClick = false; evtData.pointerPress = null; evtData.rawPointerPress = null; } if (!wasDragging) { mayLongPress = false; ExecuteEvents.ExecuteHierarchy(evtData.pointerDrag, evtData, ExecuteEvents.beginDragHandler); OnInteractionNeeded(evtData.pointerDrag.IsInteractable() ? Interaction.DraggingStarted : Interaction.DraggingStartedDisabled); IsDragging = true; } var dragObj = evtData.pointerDrag; if (dragObj == null) { dragObj = evtData.pointerPress; } evtData.pointerDrag = ExecuteEvents.ExecuteHierarchy(dragObj, evtData, ExecuteEvents.dragHandler); OnInteractionNeeded(Interaction.Dragged); } else if (wasDragging && !IsPressed) { ExecuteEvents.ExecuteHierarchy(evtData.pointerDrag, evtData, ExecuteEvents.endDragHandler); OnInteractionNeeded(Interaction.DraggingEnded); evtData.pointerDrag = null; IsDragging = false; } } }
public IEventSystemHandler Process(JuniperPointerEventData eventData, float pixelDragThresholdSquared, List <KeyCode> keyPresses) { if (buttonEvent.buttonValueName != buttonName) { SetButton(buttonEvent.GetButtonValue <ButtonIDType>()); } IsPressed = ButtonPressedNeeded(button); var evtData = ClonedPointerEventNeeded(buttonEvent.GetInstanceID(), eventData); evtData.keyCode = buttonEvent.inputKey; switch (evtData.keyCode) { case KeyCode.Mouse0: evtData.button = InputButton.Left; break; case KeyCode.Mouse1: evtData.button = InputButton.Right; break; case KeyCode.Mouse2: evtData.button = InputButton.Middle; break; default: evtData.button = (InputButton)(-1); break; } TestUpDown(evtData, keyPresses); TestDrag(evtData, pixelDragThresholdSquared); if (evtData.pointerEnter != null) { return(evtData.pointerEnter.GetComponent <IEventSystemHandler>()); } else { return(null); } }
protected override IEventSystemHandler ProcessButtons(JuniperPointerEventData evtData, float pixelDragThresholdSquared, List <KeyCode> keyPresses) { var a = base.ProcessButtons(evtData, pixelDragThresholdSquared, keyPresses); var b = touchPadButtons.Process(evtData, pixelDragThresholdSquared, keyPresses); var c = triggerButtons.Process(evtData, pixelDragThresholdSquared, keyPresses); return(a ?? b ?? c); }
public void OnClick(JuniperPointerEventData evt) { onClick?.Invoke(evt); Click?.Invoke(this, evt); if (evt.clickCount == 2) { OnDoubleClick(evt); } }
public IEventSystemHandler Process(JuniperPointerEventData eventData, float pixelDragThresholdSquared, List <KeyCode> keyPresses) { IEventSystemHandler eventTarget = null; foreach (var btn in buttons) { eventTarget = btn.Process(eventData, pixelDragThresholdSquared, keyPresses); } return(eventTarget); }
protected JuniperPointerEventData Clone(int pointerDataID, JuniperPointerEventData evtData) { if (InputModule != null) { return(InputModule.Clone(pointerDataID, evtData)); } else { return(null); } }
private JuniperPointerEventData OnClonedPointerEventNeeded(int pointerID, JuniperPointerEventData donor) { return(ClonedPointerEventNeeded?.Invoke(pointerID, donor)); }
private void TestUpDown(JuniperPointerEventData evtData, List <KeyCode> keyPresses) { IsUp = ButtonUpNeeded(button); IsDown = ButtonDownNeeded(button); if (IsDown) { mayLongPress = true; buttonDownTime = Time.unscaledTime; dragDistance = 0; evtData.rawPointerPress = evtData.pointerEnter; evtData.pressPosition = evtData.position; evtData.pointerPressRaycast = evtData.pointerCurrentRaycast; evtData.eligibleForClick = true; evtData.pointerPress = ExecuteEvents.ExecuteHierarchy(evtData.pointerEnter, evtData, ExecuteEvents.pointerDownHandler); evtData.pointerDrag = ExecuteEvents.ExecuteHierarchy(evtData.pointerEnter, evtData, ExecuteEvents.initializePotentialDrag); buttonEvent.OnDown(evtData); if (evtData.pointerPress != null) { OnInteractionNeeded(evtData.pointerPress.IsInteractable() ? Interaction.Pressed : Interaction.PressedDisabled); } } var deltaTime = Time.unscaledTime - buttonDownTime; evtData.eligibleForClick = deltaTime < THRESHOLD_CLICK; if (IsUp) { ExecuteEvents.ExecuteHierarchy(evtData.pointerPress, evtData, ExecuteEvents.pointerUpHandler); buttonEvent.OnUp(evtData); if (evtData.pointerPress != null) { InteractionNeeded(Interaction.Released); } var target = evtData.pointerCurrentRaycast.gameObject; if (evtData.eligibleForClick) { ++evtData.clickCount; evtData.clickTime = Time.unscaledTime; evtData.selectedObject = ExecuteEvents.ExecuteHierarchy(evtData.pointerPress, evtData, ExecuteEvents.pointerClickHandler); buttonEvent.OnClick(evtData); if (evtData.pointerPress != null) { OnInteractionNeeded(evtData.selectedObject.IsInteractable() ? Interaction.Clicked : Interaction.ClickedDisabled); } } else if (evtData.pointerDrag != null) { ExecuteEvents.ExecuteHierarchy(target, evtData, ExecuteEvents.dropHandler); } evtData.pointerPress = null; evtData.rawPointerPress = null; } else if (IsPressed && mayLongPress) { if (deltaTime < THRESHOLD_LONG_PRESS) { ExecuteEvents.ExecuteHierarchy(evtData.pointerPress, evtData, LongPressEvents.longPressUpdateHandler); } else { mayLongPress = false; ExecuteEvents.ExecuteHierarchy(evtData.pointerPress, evtData, LongPressEvents.longPressHandler); buttonEvent.OnLongPress(evtData); if (evtData.pointerPress != null) { OnInteractionNeeded(evtData.selectedObject.IsInteractable() ? Interaction.Clicked : Interaction.ClickedDisabled); } keyPresses.MaybeAdd(evtData.keyCode); } } }
protected virtual IEventSystemHandler ProcessButtons(JuniperPointerEventData evtData, float pixelDragThresholdSquared, List <KeyCode> keyPresses) { return(nativeButtons.Process(evtData, pixelDragThresholdSquared, keyPresses)); }
public void OnUp(JuniperPointerEventData evt) { IsPressed = false; onUp?.Invoke(evt); Up?.Invoke(this, evt); }
public void OnLongPress(JuniperPointerEventData evt) { onLongPress?.Invoke(evt); LongPress?.Invoke(this, evt); }
private void OnDoubleClick(JuniperPointerEventData evt) { onDoubleClick?.Invoke(evt); DoubleClick?.Invoke(this, evt); }
public void OnDown(JuniperPointerEventData evt) { IsPressed = true; onDown?.Invoke(evt); Down?.Invoke(this, evt); }
public override void Process(JuniperPointerEventData evtData, float pixelDragThresholdSquared, List <KeyCode> keyPresses, bool paused) { target = evtData.pointerCurrentRaycast.gameObject; base.Process(evtData, pixelDragThresholdSquared, keyPresses, paused); }