private MenuBase OnClickCheck(MenuEntry entry, MouseButtons buttons, Vector2 mousePosition) { if (!entry.IsVisible) { return(null); } if (!entry.IsInsideMenu(mousePosition)) { return(null); } if (entry.IsInside(mousePosition)) { entry.OnClick(buttons, mousePosition); return(entry); } MenuEntry hoveredEntry = null; foreach (var menu in entry.Children.OfType <MenuEntry>()) { if (this.OnClickCheck(menu, buttons, mousePosition) != null) { hoveredEntry = menu; break; } } if (hoveredEntry != null) { if (!hoveredEntry.IsCollapsed) { entry.Children.OfType <MenuEntry>().Where(x => x != hoveredEntry).ForEach(x => x.IsCollapsed = true); } return(hoveredEntry); } if (!entry.IsCollapsed) { foreach (var item in entry.Children.OfType <MenuItemEntry>()) { if (item.IsInside(mousePosition)) { item.OnClick(buttons, mousePosition); return(item); } } } return(null); }
private MenuBase OnInsideCheck(MenuEntry entry, Vector2 mousePosition) { if (!entry.IsVisible) { return(null); } if (!entry.IsInsideMenu(mousePosition)) { return(null); } if (entry.IsInside(mousePosition)) { return(entry); } foreach (var menu in entry.Children.OfType <MenuEntry>()) { var hoveredEntry = this.OnInsideCheck(menu, mousePosition); if (hoveredEntry != null) { return(hoveredEntry); } } if (!entry.IsCollapsed) { foreach (var item in entry.Children.OfType <MenuItemEntry>()) { if (item.IsInside(mousePosition)) { return(item); } } } return(null); }