Example #1
0
 void _handle_up(ICogaManager coga)
 {
     isMouseDown = false;
     if (isDragging)
     {
         OnDragEnd?.Invoke(Parent);
         coga.UnlockHover();
     }
     else
     {
         if (LongClickingEnabled)
         {
             // With long clicking enabled, allow early cancel out and
             // only long click past the const delay.
             if (mouseDownTime < MouseClickDelay)
             {
                 _update_click(coga);
             }
             else
             {
                 OnLongClick?.Invoke(Parent);
                 OnEndClicking?.Invoke(Parent);
             }
         }
         else
         {
             // If we don't need to worry about the long click,
             // just always click.
             _update_click(coga);
         }
     }
 }
Example #2
0
        public void Update(float deltaTime)
        {
            // Residual clicking handling.
            if (isMouseDown && Parent.Manager.IsClickReleased)
            {
                _handle_up(Parent.Manager);
            }
            // Hover management.
            var IsHovered = Parent.Manager.GetHover() == Parent;

            if (IsHovered == false && WasHoveredLastFrame == true)
            {
                OnUnhover?.Invoke(Parent);
            }
            else if (IsHovered == true && WasHoveredLastFrame == false)
            {
                OnHover?.Invoke(Parent);
            }

            WasHoveredLastFrame = IsHovered;

            if (double_click_timer > 0f)
            {
                double_click_timer -= deltaTime;
                if (double_click_timer <= 0f)
                {
                    OnClick?.Invoke(Parent);
                    OnEndClicking?.Invoke(Parent);
                    has_clicked = false;
                }
            }

            // Clicking related input.
            if (Parent.Manager.GetHover() == Parent)
            {
                _update(Parent.Manager, deltaTime);
            }
        }
Example #3
0
 void _update_click(ICogaManager coga)
 {
     if (DoubleClickingEnabled)
     {
         if (has_clicked)
         {
             OnDoubleClick?.Invoke(Parent);
             OnEndClicking?.Invoke(Parent);
             has_clicked        = false;
             double_click_timer = -1f;
         }
         else
         {
             has_clicked        = true;
             double_click_timer = MouseClickDelay;
         }
     }
     else
     {
         OnClick?.Invoke(Parent);
         OnEndClicking?.Invoke(Parent);
         has_clicked = false;
     }
 }