Capturing mouse input in a Slate widget
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:
As you can see, I've hooked up an event delegate that calls a function on trigger. Here's the declaration:
And here's the function:
I've bound the function to the delegate like so:
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 :D
asked Mar 26 '14 at 06:22 PM in C++ Programming
With regard to attribute binding, you can just do: OnMouseButtonDown(this, &SPlanetStatusWidget::OnToggleClick)
answered Mar 26 '14 at 06:33 PM
Jamie Dale STAFF
Hey, I haven't code the code in front of me at the moment, but it looks like you want to bind the on mouse button down to a delegate that invokes SPlanetStatusWidget::OnToggleClick.
If so, I think this code should do what you want:
(Assuming 'this' is an SPlanetStatusWidget*)
If you want something to act like a button you should use an actual button widget. The button widget's content and style can be completely customized to get the look you desire.
You'll want something like the following.
Hi both, and thanks for your answers!
That's more or less exactly what I've done, though I've used an iseparate delegate instead...
Just to make sure that wasn't the issue, I've now tried your method of just passing the function as a binding, without the separate delegate, but it isn't triggered.
I'm wondering what I could've missed?
I noticed that if I hold down the left mouse button over the image, the rest of the scene stops updating/rendering.
answered Mar 26 '14 at 07:03 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here