How to stop Slate from "turning off" Shift key?

We have a bunch of buttons in our in-game HUD that you can press to build stuff. Essentially, you press the button, and it starts “sticky-dragging” a building (it’s a strategy game).

We recently added functionality to allow you to do “quick placement mode” by holding down the Shift key. If you hold down shift, then the building you’re sticky-dragging is supposed to stay in sticky-drag mode so you can place multiple instances of it.

That’s the theory. In practice, we’re finding that whether or not this works depends on whether you start pressing Shift before or after clicking the button with the mouse! Holding down Shift before clicking the Slate button causes it to ignore the Shift key. If you work until after you’ve clicked on the button with the mouse, it works fine.

Our code simply checks this:

if( IsInputKeyDown( EKeys::LeftShift ) )
{
// multi-placement mode …
}

… but Slate is somehow stealing the keyboard event from us at the moment you click the Slate button with the mouse, even though we’re not doing anything with the keyboard focus or anything like that.

Even commenting out the call to

	FSlateApplication::Get().SetKeyboardFocus(SharedThis(this));

at initialization has no effect.

We’re planning on removing Slate from our codebase soon, but in the meantime, is there a good way to work around this?

“We’re planning on removing Slate from our codebase soon,” that sounds like the real solution to me, progress will be very fast after that :slight_smile:

I’ve implemented absolutely every user-interface mechanic I could have ever wanted with completely custom aesthetics, feeling a lack of nothing and a gain of a totally unique feel, using only HUD class :slight_smile:

But straddling both systems sounds like it will just keep creating conflict one way or another till one system is picked.

#2D Marquee/Box Selection

Have you seen my box selection mechanic? I can explain how it works if you need 2d box selection of 3d world :slight_smile:

Rocket Forum Link

http://forums.epicgames.com/threads/983100-I-Made-a-Red-Blood-Cell-Spiral-Galaxy

Thanks for the suggestions, but that’s not quite what I’m looking for; we need a fix or workaround for this by the end of the day Tuesday.

On the surface this sounds very similar to the slate IsFocusable issue you had previously:

https://rocket.unrealengine.com/questions/13182/mouse-down-on-slate-widget-causing-space-bar-to-re.html

If that isn’t it and you’re looking for a quick fix you could try FSlateApplication::Get().GetModifierKeys().IsShiftDown() which will check the hardware state rather than what the game thinks the state is.

Thanks so much, Marc! Calling FSlateApplication::Get().GetModifierKeys().IsShiftDown() fixed it :slight_smile: