Beispiel #1
0
        public bool OnMouseEvent(MouseEventID id, Vector2 pos)
        {
            if (currentHover != null && currentHover.TestHit(pos))
            {
                currentHover.OnEvent(id, pos);
                return(id != MouseEventID.MouseMove);
            }

            if (id == MouseEventID.MouseMove)
            {
                MenuItem button = Children.FirstOrDefault(b => b.TestHit(pos));
                if (button != null)
                {
                    currentHover?.SetHovered(false);
                    currentHover = button;
                    button.SetHovered(true);
                }
                return(false);
            }

            if (Bounds.Contains(pos) && id == MouseEventID.LeftButtonDown)
            {
                visible      = !visible;
                currentHover = null;
                Children.ForEach(button => button.SetVisible(visible));
                return(true);
            }

            return(false);
        }
Beispiel #2
0
 public void OnEvent(MouseEventID id, Vector2 pos)
 {
     if (id == MouseEventID.MouseMove)
     {
         if (TestBounds(pos))
         {
             HandleEvent(id, pos);
             if (currentHover != null)
             {
                 currentHover.SetHovered(false);
                 currentHover = null;
             }
             return;
         }
         if (currentHover != null)
         {
             if (currentHover.TestHit(pos))
             {
                 currentHover.OnEvent(id, pos);
                 return;
             }
             currentHover.SetHovered(false);
         }
         MenuItem childAt = Children.FirstOrDefault(current => current.TestHit(pos));
         if (childAt != null)
         {
             childAt.SetHovered(true);
             currentHover = childAt;
             return;
         }
         currentHover = null;
     }
     else
     {
         if (TestBounds(pos))
         {
             HandleEvent(id, pos);
         }
         else
         {
             currentHover?.OnEvent(id, pos);
         }
     }
 }
Beispiel #3
0
 public void OnEvent(MouseEventID id, Vec2 pos)
 {
     if (id == MouseEventID.MouseMove)
     {
         if (this.TestBounds(pos))
         {
             this.HandleEvent(id, pos);
             if (this.currentHover != null)
             {
                 this.currentHover.SetHovered(false);
                 this.currentHover = null;
             }
             return;
         }
         if (this.currentHover != null)
         {
             if (this.currentHover.TestHit(pos))
             {
                 this.currentHover.OnEvent(id, pos);
                 return;
             }
             this.currentHover.SetHovered(false);
         }
         MenuItem childAt = this.GetChildAt(pos);
         if (childAt != null)
         {
             childAt.SetHovered(true);
             this.currentHover = childAt;
             return;
         }
         this.currentHover = null;
         return;
     }
     else
     {
         if (this.TestBounds(pos))
         {
             this.HandleEvent(id, pos);
             return;
         }
         if (this.currentHover != null)
         {
             this.currentHover.OnEvent(id, pos);
         }
         return;
     }
 }