[4.6.1] UMG Frontend, C++ Backend

I was hoping I could design the user interface with UMG, but have most of the logic for events in C++ as opposed to blueprint.
Is there a decent tutorial/source somewhere for this?

I have tried this tutorial with 4.6.1 and it results in errors coming from the UE4 API for when I extend UUserWidget.
.

EDIT: The wiki entry is correct, my issue was putting the Runtime/UMG includes in my [ProjectName].cpp file instead of where they should have resided in the [ProjectName].h. Thank you both I appreciate your patience!

Hey there, if you mean you want to extend events like Tick and OnKeyDown, then you can easily :slight_smile:

All the BlueprintNativeEvent functions in the UUserWidget can be overrided as long as you override the generated c++ functions themselves, ie : _Implementation.

eg:

	virtual FEventReply OnKeyDown_Implementation(FGeometry MyGeometry, FKeyboardEvent InKeyboardEvent) override;
	virtual FEventReply OnControllerButtonPressed_Implementation(FGeometry MyGeometry, FControllerEvent ControllerEvent) override;
	virtual FEventReply OnControllerAnalogValueChanged_Implementation(FGeometry MyGeometry, FControllerEvent ControllerEvent) override;
	virtual FEventReply OnMouseWheel_Implementation(FGeometry MyGeometry, const FPointerEvent& MouseEvent) override;

	virtual	void Tick_Implementation(FGeometry MyGeometry, float InDeltaTime) override;

Let me know if you have any problems with this.

Hello if you have time please let me know what parts are giving you truble and i will update the tutorial.

Also there are a link to a tutorial about delegates for a extended User Wdget at the bottom of the wiki page you linked.

Note: Be warned delegates added in code for UMG widgets comes with its one head akes.

Can you paste your code to the definition using ESlateCheckBoxState. If its a UProperty, remember you will need to use it like:

TEnumAsByte < ESlateCheckBoxState::Type >

Otherwise you also need to make sure you have Slate.h included as that will include the SCheckBox.h you need for that namespace.

Its hard to know without seeing where you are trying to use that enum.

The issue pops up when I include “Blueprint/UserWidget.h” in my widget’s class. The other includes and dependencies listed in the wiki seem to work.

'ESlateCheckBoxState' : is not a class or namespace name

Are there additional libraries I should be concerned with?

Did you add the modules for UMG and Slate?

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "UMG", "Slate", "SlateCore", "PhysX", "APEX", "Landscape"});

: The only code that is written is the code that is shown in the wiki.

#pragma once

#include "Blueprint/UserWidget.h"
#include "RoMMainMenuWidget.generated.h"

/**
*
*/
UCLASS()
class ROM_API URoMMainMenuWidget : public UUserWidget
{
	GENERATED_UCLASS_BODY()
};

: Yes, UMG, Slate, SlateCore have been added as depenencies.

        PublicDependencyModuleNames.AddRange(
            new string[] {
				"Core",
				"CoreUObject",
				"Engine",
                "InputCore",
				"OnlineSubsystem",
				"OnlineSubsystemUtils",
				"AssetRegistry",
                "AIModule",
                "UMG",
				"Slate",
				"SlateCore",
			}
        );

Is there some other library I am missing? Are you both using 4.6.1?

Gah! It was my fault, I had put the Runtime/UMG includes in my RoM.cpp instead of where the wiki says it should be in the RoM.h.

This was not my core issue but this snippet will in no doubt come in handy, thank you!

I have a UUserWidget inside of another UUserWidget. The outer widget always seems to steal the event for OnMouseButtonDown_Implementation() before the child can get it. Is there are way around this?

Not off the top of my head, I am pretty sure those functions only work on the outer user widget.

In a case like that, where I wanted a complicated widget inside a user widget, I have just wrote a new UWidget wrapper around a custom SWidget

That’s so strange because the blueprint implementation works perfectly, makes me wonder if this is the intended result.