I am currently making an android app which uses touch events.
I have a button with an “On Pressed” event, when I press on the button I also want to handle the “Touch1” event of my pawn, so basically I want to handle two events at the same time.
The issue : once I press on the button the “On Pressed” event is handled, therefore the touch event doesn’t reach the pawn, what’s the easiest/best way to pass events generated by the HUD to the pawn?
Currently, I overrided the “OnTouchMoved” function in my HUD, and I use that function to call the “Touch1” function of my pawn, but I am not a big fan of that solution, there might be an easier way.
The issue : once I press on the button
the “On Pressed” event is handled,
therefore the touch event doesn’t
reach the pawn, what’s the
easiest/best way to pass events
generated by the HUD to the pawn?
Buttons are as great as they are terrible. The moment you try to make them do something out of the ordinary, you hit a road block. If you must use a traditional button, the current solution you’re implementing should work OK, even though it does not seem elegant.
Another way to handle it (more gracefully) is to not use a button. As you said, pressing a button handles the call and the Player Controller receives no input as the click was fully consumed.
Now, if you were to use a humble border instead of a button, you could override both onMouseDown and Up separately, each allowing you to pass either Handled or, in this very case, Unhandled. The latter would allow the click to tunnel to the layers underneath and, providing no other widget intercepts it along they way, reach the Player Controller / Pawn.
You’d lose the fancy functionality of the button states, though. They can be added to the border but that’s a lot of work.
I never seriously looked into Slate, but it may be fairly straightforward to modify what value the button’s Event Reply returns.