//==============================
// VRMenuEventHandler::DispatchToPath
bool VRMenuEventHandler::DispatchToPath( OvrGuiSys & guiSys, VrFrame const & vrFrame, 
        VRMenuEvent const & event, Array< menuHandle_t > const & path, bool const log ) const
{
	// send to the focus path only -- this list should be parent -> child order
	for ( int i = 0; i < path.GetSizeI(); ++i )
	{
		VRMenuObject * obj = guiSys.GetVRMenuMgr().ToObject( path[i] );
		char const * const indent = "                                                                ";
		// set to 
		if ( obj != NULL && DispatchToComponents( guiSys, vrFrame, event, obj ) )
		{
			if ( log )
			{
				LOG( "%sDispatchToPath: %s, object '%s' consumed event.", &indent[64 - i * 2],
						VRMenuEvent::EventTypeNames[event.EventType], ( obj != NULL ? obj->GetText().ToCStr() : "<null>" ) );
			}	
			return true;    // consumed by a component
		}
		if ( log )
		{
			LOG( "%sDispatchToPath: %s, object '%s' passed event.", &indent[64 - i * 2],
					VRMenuEvent::EventTypeNames[event.EventType], obj != NULL ? obj->GetText().ToCStr() : "<null>" );
		}
	}
	return false;
}
//==============================
// VRMenuEventHandler::BroadcastEvent
bool VRMenuEventHandler::BroadcastEvent( OvrGuiSys & guiSys, VrFrame const & vrFrame, 
        VRMenuEvent const & event, VRMenuObject * receiver ) const
{
	ASSERT_WITH_TAG( receiver != NULL, "VrMenu" );

	// allow parent components to handle first
	if ( DispatchToComponents( guiSys, vrFrame, event, receiver ) )
	{
		return true;
	}

	// if the parent did not consume, dispatch to children
	int numChildren = receiver->NumChildren();
	for ( int i = 0; i < numChildren; ++i ) 
	{
		menuHandle_t childHandle = receiver->GetChildHandleForIndex( i );
		VRMenuObject * child = guiSys.GetVRMenuMgr().ToObject( childHandle );
		if ( child != NULL && BroadcastEvent( guiSys, vrFrame, event, child ) )
		{
			return true;    // consumed by child
		}
	}
	return false;
}
//==============================
// VRMenuEventHandler::BroadcastEvent
bool VRMenuEventHandler::BroadcastEvent( App * app, VrFrame const & vrFrame, OvrVRMenuMgr & menuMgr,
        VRMenuEvent const & event, VRMenuObject * receiver ) const
{
    DROID_ASSERT( receiver != NULL, "VrMenu" );

    // allow parent components to handle first
    if ( DispatchToComponents( app, vrFrame, menuMgr, event, receiver ) )
    {
        return true;
    }

    // if the parent did not consume, dispatch to children
    int numChildren = receiver->NumChildren();
    for ( int i = 0; i < numChildren; ++i )
    {
        menuHandle_t childHandle = receiver->GetChildHandleForIndex( i );
        VRMenuObject * child = menuMgr.ToObject( childHandle );
        if ( child != NULL && BroadcastEvent( app, vrFrame, menuMgr, event, child ) )
        {
            return true;    // consumed by child
        }
    }
    return false;
}