Mouse-down on Slate widget causing space bar to release?

I have the following in my DefaultInput.ini

+ActionMappings=(ActionName="ToggleOverlayBegin", Key=SpaceBar)
+ActionMappings=(ActionName="ToggleOverlayEnd", Key=SpaceBar)

and the following in my player controller class:

BIND_ACTION(InputComponent, "ToggleOverlayBegin", IE_Pressed, &APrototypeOCPlayerController::ToggleOverlayBegin);
BIND_ACTION(InputComponent, "ToggleOverlayEnd", IE_Released, &APrototypeOCPlayerController::ToggleOverlayEnd);

I am finding that if I hold down the space bar and press any mouse button while the mouse is over a button in Slate, my ToggleOverlayEnd() function gets called, even if the Slate widget that gets clicked on has no OnClicked delegate. Furthermore, if I map any function to the OnClicked of a Slate widget, that function never gets called.

What’s even stranger is, if I call IsInputKeyDown(EKeys::SpaceBar) from inside my player controller class, I STILL see the same bizarre behavior. It’s as if clicking on the Slate widget is forcing the key-up event to occur on the space bar without ever registering the OnClicked and calling the function I’ve assigned to it.

I’m deeply sorry about the untimely response, between the holiday break and some other distractions this question fell through the cracks.

I believe the cause of your issue is that when a slate widget is given focus other widgets, including in this case the game viewport, get a lost focus message. The game viewport’s lost focus clears the PlayerInput key state (causing Released events for all Pressed keys) because we don’t want keys to get stuck if you alt-tab or bring up a menu and then release the key at that point.

I think that if when you are creating your SButton you were to add .IsFocusable(false) to its arguments you would not see the behavior you currently are.

Thanks – it’s not an SButton but a button copied and pasted from the SStrategyButtonWidget in the StrategyGame example. It doesn’t seem to have an .IsFocusable().

In any event, this is low-priority for now.

Side note: I am hoping that in the future, Slate will become more of a fully-integrated part of the engine. It seems like a licensee needs to add a lot of stuff into their app (as I did by copying and pasting and adapting from the StrategyGame example and following all the tutorials up on the forums) to get Slate functional even at a basic level. I think this is an area where the engine could benefit from a lot more attention.

Ah, if you’re starting from StrategyButtonWidget you’ll notice that it has a SupportsKeyboardFocus() override that returns true. Change that to false and that will have the same effect that SButton’s IsFocusable attribute has.