Hey everyone.
I’m having an issue where I’ve hooked up Slate to my HUD class and got a widget to render.
This widget consists of a TextBlock and an SImage, side-by-side.
I want the SImage to act more or less like a button, so when clicked it will expand a submenu and the SImage will change appearance.
Here’s the Construct code for the SImage:
+ SHorizontalBox::Slot()
.AutoWidth()
[
SAssignNew(ToggleButton, SImage)
.Image(&PlanetStatusStyle->ToggleButtonCollapsed)
.OnMouseButtonDown(FPointerEventHandler(ToggleClickEvent))
]
As you can see, I’ve hooked up an event delegate that calls a function on trigger.
Here’s the declaration:
TBaseDelegate_RetVal_TwoParams<FReply, const FGeometry&, const FPointerEvent&> ToggleClickEvent;
And here’s the function:
FReply SPlanetStatusWidget::OnToggleClick(const FGeometry& Geometry, const FPointerEvent& Event)
{
// Toggle dropdown menu visibility.
MenuVisibility = MenuVisibility == EVisibility::Collapsed ? EVisibility::Visible : EVisibility::Collapsed;
// Notify UE event system that event was handled.
return FReply::Handled();
}
I’ve bound the function to the delegate like so:
ToggleClickEvent.BindRaw(this, &SPlanetStatusWidget::OnToggleClick);
Now with all this out of the way, I was hoping I’d get a triggered breakpoint inside the function when the image was clicked. Alas, no luck. So I studied on, mainly in StrategyGame sample.
I found out that there was a virtual function returning whether or not keyboard focus is supported by the widget. As far as I understand keyboard and mouse focus goes hand-in-hand (and I didn’t find anything related to mouse focus), so I made an override of that and returned true.
Still nothing… My face is now starting to adopt a red/blue hue.
So I plowed on - found, inside the playercontroller, that there are a few bools there that could be related to it.
So I set bEnableClickEvents to true and bEnableTouchEvents to true.
Still nothing… And, frankly, now I’m out of ideas…
So if anyone have any input, I’d love to hear it!
Thanks in advance guys - firstly for taking the time reading this wall of text and secondly for any useful info