private void OnMouseDown(Object s, MouseEventArgs e)
{
// What item are we over?
int item = ItemFromPoint(new Point(e.X, e.Y));
if (item != -1)
{
MenuItem menuItem = ItemSelected(item);
// If there were no sub items, then we need to "PerformClick".
if (menuItem.MenuItems.Count == 0)
{
PopDown();
menuItem.PerformClick();
}
else
{
return;
}
}
// Do we need to pass the mouse down along?
if (MouseDown != null)
{
// Convert the mouse co-ordinates relative to the associated control (form).
MouseDown(this, CreateParentMouseArgs(e));
}
}