SidebarLibrary.Menus.MenuControl.GenerateShortcut C# (CSharp) Method

GenerateShortcut() protected method

protected GenerateShortcut ( Shortcut sc, MenuCommandCollection mcc ) : bool
sc Shortcut
mcc SidebarLibrary.Collections.MenuCommandCollection
return bool
		protected bool GenerateShortcut(Shortcut sc, MenuCommandCollection mcc)
		{
			foreach(MenuCommand mc in mcc)
			{
				// Does the command match?
				if (mc.Enabled && (mc.Shortcut == sc))
				{
					// Generate event for command
					mc.OnClick(EventArgs.Empty);

					return true;
				}
				else
				{
					// Any child items to test?
					if (mc.MenuCommands.Count > 0)
					{
						// Recursive descent of all collections
						if (GenerateShortcut(sc, mc.MenuCommands))
							return true;
					}
				}
			}

			return false;
		}