Beispiel #1
0
        public void OnMouseWheel(MouseInputEvent evt)
        {
            if (verticalScrollingEnabled)
            {
                float actualContentHeight  = children[0].layoutResult.actualSize.height;
                float visibleContentHeight = layoutResult.ActualHeight;
                if (!isScrollingY || (int)Mathf.Sign(evt.ScrollDelta.y) != (int)Mathf.Sign(fromScrollY - toScrollY))
                {
                    accumulatedScrollSpeedY = scrollSpeedY;
                }
                else
                {
                    accumulatedScrollSpeedY *= 1.2f;
                }
                scrollDeltaY = -evt.ScrollDelta.y * accumulatedScrollSpeedY / (actualContentHeight - visibleContentHeight);
                fromScrollY  = scrollPercentageY;
                if (scrollDeltaY != 0)
                {
                    toScrollY = Mathf.Clamp01(fromScrollY + scrollDeltaY);
                    if (fromScrollY != toScrollY)
                    {
                        evt.StopPropagation();
                        elapsedTotalTime = 0;
                        isScrollingY     = true;
                    }
                }
            }

            if (horizontalScrollingEnabled)
            {
                float actualContentWidth  = children[0].layoutResult.actualSize.width;
                float visibleContentWidth = layoutResult.ActualWidth;
                if (!isScrollingX || (int)Mathf.Sign(-evt.ScrollDelta.x) != (int)Mathf.Sign(fromScrollX - toScrollX))
                {
                    accumulatedScrollSpeedX = scrollSpeedX;
                }
                else
                {
                    accumulatedScrollSpeedX *= 1.2f;
                }
                scrollDeltaX = evt.ScrollDelta.x * accumulatedScrollSpeedX / (actualContentWidth - visibleContentWidth);
                if (scrollDeltaX != 0)
                {
                    fromScrollX = scrollPercentageX;
                    toScrollX   = Mathf.Clamp01(fromScrollX + scrollDeltaX);
                    if (fromScrollX != toScrollX)
                    {
                        evt.StopPropagation();
                        elapsedTotalTime = 0;
                        isScrollingX     = true;
                    }
                }
            }
        }
Beispiel #2
0
        public void OnClickHorizontal(MouseInputEvent evt)
        {
            float x = evt.MousePosition.x - layoutResult.screenPosition.x;

            float contentAreaWidth = layoutResult.ContentAreaWidth;
            float contentWidth     = children[0].layoutResult.actualSize.width;

            if (contentWidth == 0)
            {
                return;
            }

            float handleWidth = (contentAreaWidth / contentWidth) * contentAreaWidth;

            float handlePosition = (contentAreaWidth - handleWidth) * scrollPercentageX;

            float pageSize = evt.element.layoutResult.allocatedSize.width / contentWidth;

            if (x < handlePosition)
            {
                pageSize = -pageSize;
            }

            ScrollToHorizontalPercent(scrollPercentageX + pageSize);

            evt.StopPropagation();
        }
Beispiel #3
0
        public void OnClickVertical(MouseInputEvent evt)
        {
            float contentAreaHeight  = layoutResult.ContentAreaHeight;
            float contentHeight      = children[0].layoutResult.actualSize.height;
            float paddingBorderStart = layoutResult.VerticalPaddingBorderStart;
            float y = evt.MousePosition.y - layoutResult.screenPosition.y - paddingBorderStart;

            if (contentHeight == 0)
            {
                return;
            }

            float handleHeight = (contentAreaHeight / contentHeight) * contentAreaHeight;

            float handlePosition = (paddingBorderStart + contentAreaHeight - handleHeight) * scrollPercentageY;

            float pageSize = evt.element.layoutResult.allocatedSize.height / contentHeight;

            if (y < handlePosition)
            {
                pageSize = -pageSize;
            }

            ScrollToVerticalPercent(scrollPercentageY + pageSize);

            evt.StopPropagation();
        }
Beispiel #4
0
        public void OnMouseClick(MouseInputEvent evt)
        {
            bool hadFocus = hasFocus;

            if (evt.IsConsumed || (!hasFocus && !Input.RequestFocus(this)))
            {
                return;
            }

            if (!hadFocus && selectAllOnFocus)
            {
                return;
            }

            blinkStartTime = Time.unscaledTime;
            Vector2 mouse = evt.MousePosition - layoutResult.screenPosition - layoutResult.ContentRect.position;

            mouse += textScroll;

            if (evt.IsDoubleClick)
            {
                selectionRange = textElement.textInfo.SelectWordAtPoint(mouse);
            }
            else if (evt.IsTripleClick)
            {
                selectionRange = textElement.textInfo.SelectLineAtPoint(mouse);
            }
            else
            {
                selectionRange = new SelectionRange(textElement.textInfo.GetIndexAtPoint(mouse));
                ScrollToCursor();
            }

            evt.StopPropagation();
        }
Beispiel #5
0
 public void SelectElement(MouseInputEvent evt, int index)
 {
     selectedIndex = index;
     selectedValue = options[selectedIndex].Value;
     selecting     = false;
     evt.StopPropagation();
     evt.Consume();
 }
Beispiel #6
0
            public void HandleMouseUpChild(MouseInputEvent evt, int index)
            {
                clickedChildIndex = index;
                if (shouldStopPropagation)
                {
                    evt.StopPropagation();
                }

                clickList.Add("up:child" + index);
            }
Beispiel #7
0
            public void OnAnyMouseDown(MouseInputEvent evt)
            {
                if (shouldStopPropagation)
                {
                    evt.StopPropagation();
                }

                clickList.Add("down:root");
                wasMouseDown = true;
            }
Beispiel #8
0
        public void Decrement(MouseInputEvent evt)
        {
            evt.StopPropagation();
            keyLockTimestamp = Time.unscaledTime;
            if (inputElement.HasDisabledAttr())
            {
                return;
            }

            Decrement();
        }
Beispiel #9
0
            public void OnMouseMove(MouseInputEvent evt)
            {
                if (ignoreMove)
                {
                    return;
                }
                if (shouldStopPropagation)
                {
                    evt.StopPropagation();
                }

                clickList.Add("move:root");
            }
Beispiel #10
0
            public void OnMouseHover(MouseInputEvent evt)
            {
                if (ignoreHover)
                {
                    return;
                }
                if (shouldStopPropagation)
                {
                    evt.StopPropagation();
                }

                clickList.Add("hover:root");
            }
Beispiel #11
0
            public void MouseExit(MouseInputEvent evt)
            {
                if (ignoreExit)
                {
                    return;
                }
                if (shouldStopPropagation)
                {
                    evt.StopPropagation();
                }

                clickList.Add("exit:root");
                wasMouseDown = true;
            }
Beispiel #12
0
            public void HandleMouseEnterChild(MouseInputEvent evt, int index)
            {
                if (ignoreEnter)
                {
                    return;
                }
                clickedChildIndex = index;
                if (shouldStopPropagation)
                {
                    evt.StopPropagation();
                }

                clickList.Add("enter:child" + index);
            }
Beispiel #13
0
        public void BeginSelecting(MouseInputEvent evt)
        {
            if (disabled)
            {
                return;
            }

            if (selecting)
            {
                InputSystem.ReleaseFocus(this);
                selecting = false;
            }
            else
            {
                selecting = InputSystem.RequestFocus(this);
            }

            AdjustOptionPosition();

            evt.StopPropagation();
            evt.Consume();
        }
Beispiel #14
0
 public void DecrementContinuously(MouseInputEvent evt)
 {
     evt.StopPropagation();
     DecrementContinuously();
 }