public bool HandleInput(MyTreeViewItem treeViewItem) { bool captured = false; if (DraggedItem == null) { if (MyGUIHelper.Contains(treeViewItem.GetPosition(), treeViewItem.GetSize(), MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y) && treeViewItem.TreeView.Contains(MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y)) { if (MyInput.Static.IsNewLeftMousePressed()) { Dragging = false; DraggedItem = treeViewItem; StartDragPosition = MyGuiManager.MouseCursorPosition; captured = true; } } } return(captured); }
public bool Contains(float x, float y) { return(MyGUIHelper.Contains(m_body.GetPosition(), m_body.GetSize(), x, y)); }
public bool HandleInputEx(bool hasKeyboardActiveControl) { if (!Visible) { return(false); } bool captured = false; // Hoover item if mouse cursor is inside its area if (TreeView.Contains(MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y) && MyGUIHelper.Contains(m_currentOrigin, m_currentSize, MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y)) { TreeView.HooveredItem = this; } if (Enabled && DragDrop != null) { captured = DragDrop.HandleInput(this); } // Single click - expand or focus item if (MyInput.Static.IsNewLeftMouseReleased()) { if (GetItemCount() > 0 && MyGUIHelper.Contains(m_currentOrigin + GetExpandIconPosition(), m_expandIconSize, MyGuiManager.MouseCursorPosition.X, MyGuiManager.MouseCursorPosition.Y)) { IsExpanded = !IsExpanded; captured = true; MyGuiSoundManager.PlaySound(GuiSounds.MouseClick); } else if (TreeView.HooveredItem == this) { TreeView.FocusItem(this); captured = true; MyGuiSoundManager.PlaySound(GuiSounds.MouseClick); } } // Double click - launch Action event if (Enabled && /*!captured && MyInput.Static.IsNewLeftMouseDoubleClick() && */ TreeView.HooveredItem == this) { if (Action != null) { DoAction(); } else if (GetItemCount() > 0) { IsExpanded = !IsExpanded; } captured = true; } // Right click - launch RightClick event if (/*!captured && */ MyInput.Static.IsNewRightMousePressed() && TreeView.HooveredItem == this) { if (RightClick != null) { RightClick(this, EventArgs.Empty); } captured = true; MyGuiSoundManager.PlaySound(GuiSounds.MouseClick); } return(captured); }