// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "Runtime/UMG/Public/UMG.h"
#include "Runtime/UMG/Public/UMGStyle.h"
#include "Runtime/UMG/Public/Slate/SObjectWidget.h"
#include "Runtime/UMG/Public/IUMGModule.h"
#include "Runtime/UMG/Public/Blueprint/UserWidget.h"
#include "Components/ScrollBox.h"
#include "BetterScrollBox.generated.h"
class UBetterScrollBox;
/**
*
*/
UCLASS(Blueprintable, BlueprintType, Category = "Custom UI Components")
class MYSHOP_API UBetterScrollBoxItem : public UUserWidget
{
GENERATED_BODY()
private:
UBetterScrollBox* scrollBoxParent;
public:
UButton* item;
virtual void OnWidgetRebuilt() override;
void UpdateScrollBoxRef(UBetterScrollBox* scrollBox);
};
/**
*
*/
UCLASS(Blueprintable, BlueprintType, Category = "Custom UI Components")
class MYSHOP_API UBetterScrollBox : public UScrollBox
{
GENERATED_BODY()
virtual void OnWidgetRebuilt() override;
};
This way, my BetterScrollBox appears under the Panels category in the UMG editor’s palette, but the BetterScrollBoxItem, that i thought would appear under the Custom category, does not appear :(.
Also, deriving from UUserWidget isn’t the approach I would take unless you’re intending users to derive from it as a widget blueprint. You should be using UWidget for normal primitive controls.
I solved the category issue, thanks a lot .
But, my UUserWidget does not appear yet under the “User Created” category
Also, the reason i’m doing this is because i have not found any “OnItemSelected” event in the ScrollBox component, so, due the fact the ScrollBox seems to use its children widgets as the shown options, i’m trying to create my own ScrollBox and ScrollBoxItem.
The goal i want to achieve is that, when the ScrollBoxItem receives an “OnClick” event, it notifies its parent ScrollBox, that raises a custom “OnItemSelected” event with the ScrollBoxItem reference.
I supposed that the BetterScrollBoxItem, due the fact of inherit from UserWidget, would appear at the “User Created” category (like when you create a new Widget blueprint) :/.
ScrollBox is not a ListView, which is what it sounds like you’re trying to create. ScrollBoxes don’t virtualize children or support the kind of interaction pattern you’re looking for, they’re just non-virtualized vertically/horizontally pan-able containers.
There’s a prototype ListView in C++ you could take and use.
Additionally - The reason it’s going under UserCreated is probably because it’s not in memory. Widget Blueprints are treated special, they have metadata written into another area of their package so that categories can be determined without loading the blueprint into memory. In fact, you my simply be unable to override the user area of categories as it’s meant to only be settable via the Category field in the designer view when you select the [My Widget] root tree node.
There’s a bunch of code in palette that assumes if it’s a UserWidget, it’s been created via a Widget Blueprint. Don’t have it in front of me to see if there’s a workaround, but like I said, the assumption is that primitive C++ controls would be made by deriving from UWidget, UUserWidget should only be used if you’re making an Abstract base class that you intent to reparent a Widget Blueprint to.
Thanks a lot for your assistance and quick responses, i will look the ListView .
See ya!
P.D: Mmm… i have tried inheriting from UListView, but the new component do not appear under any category.
I tried then editing the ListView.h, removing the Experimental specifier from the UCLASS() macro, but neither the original ListView or my own appears, is this normal? :S