KeyValues *CPPEHelper::GetInlineMaterial( const char *szmatName )
{
	if ( !szmatName )
		return NULL;

	for ( int i = 0; i < GetPPCache()->GetNumPostProcessingEffects(); i++ )
	{
		CUtlVector<CHLSL_SolverBase*> &solver = GetPPCache()->GetPostProcessingEffect(i)->hSolverArray;

		KeyValues *pKV = GetInlineMaterial( szmatName, solver );
		if ( pKV != NULL )
			return pKV;
	}

	if ( IsInEditMode() )
	{
		for ( int i = 0; i < pEditorRoot->GetNumFlowGraphs(); i++ )
		{
			CNodeView *pView = pEditorRoot->GetFlowGraph( i );

			if ( pView->GetFlowgraphType() != CNodeView::FLOWGRAPH_POSTPROC )
				continue;

			CUtlVector<CHLSL_SolverBase*> &solver = pView->AccessSolverStack_POSTPROC();

			KeyValues *pKV = GetInlineMaterial( szmatName, solver );
			if ( pKV != NULL )
				return pKV;
		}
	}

	Assert(0);

	return NULL;
}
SInlineEditableTextBlock::~SInlineEditableTextBlock()
{
	if(IsInEditMode())
	{
		// Clear the error so it will vanish.
		SetTextBoxError( FText::GetEmpty() );
	}
}
void SInlineEditableTextBlock::OnTextBoxCommitted(const FText& InText, ETextCommit::Type InCommitType)
{
	if(InCommitType == ETextCommit::OnCleared)
	{
		CancelEditMode();
		// Commit the name, certain actions might need to be taken by the bound function
		OnTextCommittedDelegate.ExecuteIfBound(Text.Get(), InCommitType);
	}
	else if(IsInEditMode())
	{
		if(OnVerifyTextChanged.IsBound())
		{
			if(InCommitType == ETextCommit::OnEnter)
			{
				FText OutErrorMessage;
				if(!OnVerifyTextChanged.Execute(InText, OutErrorMessage))
				{
					// Display as an error.
					SetTextBoxError( OutErrorMessage );
					return;
				}
			}
			else if(InCommitType == ETextCommit::OnUserMovedFocus)
			{
				FText OutErrorMessage;
				if(!OnVerifyTextChanged.Execute(InText, OutErrorMessage))
				{
					CancelEditMode();

					// Commit the name, certain actions might need to be taken by the bound function
					OnTextCommittedDelegate.ExecuteIfBound(Text.Get(), InCommitType);
				
					return;
				}
			}
			else // When the user removes all focus from the window, revert the name
			{
				CancelEditMode();

				// Commit the name, certain actions might need to be taken by the bound function
				OnTextCommittedDelegate.ExecuteIfBound(Text.Get(), InCommitType);
				return;
			}
		}
		
		ExitEditingMode();

		OnTextCommittedDelegate.ExecuteIfBound(InText, InCommitType);

		if ( !Text.IsBound() )
		{
			TextBlock->SetText( Text );
		}
	}
}
void SInlineEditableTextBlock::OnTextChanged(const FText& InText)
{
	if(IsInEditMode())
	{
		FText OutErrorMessage;

		if(OnVerifyTextChanged.IsBound() && !OnVerifyTextChanged.Execute(InText, OutErrorMessage))
		{
			SetTextBoxError( OutErrorMessage );
		}
		else
		{
			SetTextBoxError( FText::GetEmpty() );
		}
	}
}