Question about Slate syntax

I’m reading about Slate in the wiki and I was wondering about the syntax. From what I understand, this is just C++ but just formatted differently so every function call is on a separate line. I’m familiar with C++ at an early intermediate level. However, I’m wondering about the plus sign specified before creating a slot (pasted example code below).

Is this adding two pointer addresses together and using that as the index to an array? Well, not really an array because the docs say “All Slate widgets store children in child slots. (As opposed to storing a plain array of child widgets.)” I don’t know what child slots are yet but I’m guessing some sort of hash map.

Or am I completely off?



ChildSlot
    .VAlign(VAlign_Fill)
    .HAlign(HAlign_Fill)
    
        SNew(SOverlay)
        + SOverlay::Slot()
        ... more stuff ...
    ];


Hi Brisket,

Slate’s declarative syntax actually overrides operators like + and ] to do custom things. For instance, + is used to add a new slot, implemented on things like SHorizontalBox/SVerticalBox using the SLATE_SUPPORTS_SLOT macro:



#define SLATE_SUPPORTS_SLOT( SlotType ) \
		TArray< SlotType* > Slots; \
		WidgetArgsType& operator + (SlotType& SlotToAdd) \
		{ \
			Slots.Add( &SlotToAdd ); \
			return *this; \
		}


Cheers,
Michael Noland

1 Like

Ok, thanks for clearing that up.