# Problem with UI button to change protected stuff.

**URL:** <https://forums.unrealengine.com/t/problem-with-ui-button-to-change-protected-stuff/118292>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [November 3, 2018, 7:14am UTC](https://forums.unrealengine.com/t/problem-with-ui-button-to-change-protected-stuff/118292 "2018-11-03T07:14:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![LeoRocha\_GameDev](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@LeoRocha\_GameDev](https://forums.unrealengine.com/u/LeoRocha_GameDev)\
**Post date:** [November 3, 2018, 7:14am UTC](https://forums.unrealengine.com/t/problem-with-ui-button-to-change-protected-stuff/118292/1 "2018-11-03T07:14:51Z")

</div>

Hey guys, I’ll explain the whole situation. I factored my ACharacter class into an AActorComponent(where I do a lot of private/protected things) and called it CharacterComponent. Now I want to change some values of a protected UStruct inside my CharacterComponent, but using a Button. The whole part of creating the Widget Blueprint is okay, but I can’t create a UUserWidget class to handle these buttons callbacks because I need to change the protected values, so I tried to do something like this:  
I created a class inherited from my CharacterComponent class and wrote this code:

CharacterComponentUI.cpp:

```auto

#include "CharacterComponentUI.h"
#include "MenuSystem/MenuWidget.h"
#include "Blueprint/UserWidget.h"
#include "MenuInterface.h"
#include "MenuWidget.h"
#include "Components/Button.h"

bool UCharacterComponentUI::Initialize()
{
bool Success = Super::Initialize();
if (!Success) return false;

if (!ensure(STRButton != nullptr)) return false;
STRButton->OnClicked.AddDynamic(this, &UCharacterComponentUI::STRPressed);
}

void UCharacterComponentUI::STRPressed()
{
UE_LOG(LogTemp, Warning, TEXT("PRESSED STR"));
}

```

And CharacterComponentUI.h:

```auto

#include "CoreMinimal.h"
#include "CharacterComponent.h"
#include "MenuSystem/MenuWidget.h"
#include "Blueprint/UserWidget.h"
#include "MenuInterface.h"
#include "MenuWidget.h"
#include "CharacterComponentUI.generated.h"

/**
 * 
 */
UCLASS()
class MEHILOONLINE_API UCharacterComponentUI : public UCharacterComponent
{
    GENERATED_BODY()

public:
    bool Initialize();

private:
    UPROPERTY(meta = (BindWidget))
    class UButton* STRButton;

    UFUNCTION(BlueprintCallable)
    void STRPressed();
};

```

But reading this you’ll probably notice that class “UActorComponent” has no member Initialize(). I really just copied the way I did with previous Menu/button stuff. What’s the correct approach to solve my problem? Am I in the correct path?

Note: I know that I’m not using all these includes, I’ll remove the ones I’m not using later.
