public bool InjectMouseDown( SIS.MouseEventArgs evt, SIS.MouseButtonID id )
{
// only process left button when stuff is visible
if ( !cursorLayer.IsVisible || id != SIS.MouseButtonID.Left )
return false;
Vector2 cursorPos = new Vector2( cursor.Left, cursor.Top );
mTrayDrag = false;
if ( ExpandedMenu != null ) // only check top priority widget until it passes on
{
ExpandedMenu.OnCursorPressed( cursorPos );
if ( !ExpandedMenu.IsExpanded )
ExpandedMenu = null;
return true;
}
if ( Dialog != null ) // only check top priority widget until it passes on
{
Dialog.OnCursorPressed( cursorPos );
if ( mOk != null )
mOk.OnCursorPressed( cursorPos );
else
{
mYes.OnCursorPressed( cursorPos );
mNo.OnCursorPressed( cursorPos );
}
return true;
}
for ( int i = 0; i < 9; i++ ) // check if mouse is over a non-null tray
{
if ( mTrays[ i ].IsVisible && Widget.IsCursorOver( mTrays[ i ], cursorPos, 2 ) )
{
mTrayDrag = true; // initiate a drag that originates in a tray
break;
}
}
for ( int i = 0; i < mWidgets[ 9 ].Count; i++ ) // check if mouse is over a non-null tray's widgets
{
if ( mWidgets[ 9 ][ i ].OverlayElement.IsVisible &&
Widget.IsCursorOver( mWidgets[ 9 ][ i ].OverlayElement, cursorPos ) )
{
mTrayDrag = true; // initiate a drag that originates in a tray
break;
}
}
if ( !mTrayDrag )
return false; // don't process if mouse press is not in tray
Widget w;
for ( int i = 0; i < 10; i++ )
{
if ( !mTrays[ i ].IsVisible )
continue;
for ( int j = 0; j < mWidgets[ i ].Count; j++ )
{
w = mWidgets[ i ][ j ];
if ( !w.OverlayElement.IsVisible )
continue;
w.OnCursorPressed( cursorPos ); // send event to widget
SelectMenu m = w as SelectMenu;
if ( m != null && m.IsExpanded ) // a menu has begun a top priority session
{
ExpandedMenu = m;
return true;
}
}
}
return true; // a tray click is not to be handled by another party
}