UPanelSlot* UJavascriptWidget::AddChild(UWidget* Content)
{

	if (Content == nullptr)
	{
		return nullptr;
	}

	Content->RemoveFromParent();

	if (!ContentSlot)
	{
		ContentSlot = NewObject<UPanelSlot>(this, GetSlotClass());
		ContentSlot->SetFlags(RF_Transactional);
	}

	ContentSlot->Content = Content;
	
	if (Content)
	{
		Content->Slot = ContentSlot;
	}

	OnSlotAdded(Slot);

	SetRootWidget(Content);

	return ContentSlot;
}
UPanelSlot* UPanelWidget::AddChild(UWidget* Content)
{
	if ( Content == nullptr )
	{
		return nullptr;
	}

	if ( !bCanHaveMultipleChildren && GetChildrenCount() > 0 )
	{
		return nullptr;
	}

	Content->RemoveFromParent();

	UPanelSlot* PanelSlot = NewObject<UPanelSlot>(this, GetSlotClass());
	PanelSlot->SetFlags(RF_Transactional);
	PanelSlot->Content = Content;
	PanelSlot->Parent = this;

	if ( Content )
	{
		Content->Slot = PanelSlot;
	}

	Slots.Add(PanelSlot);

	OnSlotAdded(PanelSlot);

	InvalidateLayoutAndVolatility();

	return PanelSlot;
}