I’ve got a question for using Sliders with Common UI.
I’m using my Controller’s D Pad to update the value on a Slider and everything works fine. The only thing is, when I press the A Button on my Xbox Controller, the Slider’s value is reset to the middle of the Slider.
How can I prevent this ?
Here’s a small gif of my problem.
I’ve tried many methods and nothing seems to work. I can’t believe that I’m struggling that much on something that seems so simple.
I wanted to override the On Key Down event in order to manually reset the value if the Button A is pressed, but this function is never called with this button.
I’ve also checked at the tick if the Button A is pressed by checking Is Input Key Down on the Player Controller but it always return false.
It seems that the input get consumed by the UI system of Unreal.
Is there any other way to check if a key is down on Unreal ? Or is they a way to prevent a Slider from being selected with the Button A on a Gamepad ?
In the onkeydown function
If you want it to set the value of the slider > From in key event → get key → == (a) → if true → set variable for slider value to desired → return handled
If you want it to not interact with slider but you still want dpad events try using this selection method to allow the face button to pass through the ui (you still need your other buttons functionality added to this, just quick pseudo code)
Yes, I do want pressing A to do nothing.
The thing is I’ve tried to override the On Key Down event in order to return Unhandle when pressing A. But unfortunately it doesn’t work, the event is not called when pressing A.
I’ve tried in this event a simple Print of the key currently being pressed, and nothing is printed when using A or event a D-Pad key.
If nothing is being printed when you press d pad or a in the on key down event, but something is happening it is being handled somewhere else, perhaps another widget that you have open at the same time, or focus is incorrect? Need more information about how your widget is put together to say.
The thing is, even though those datas are created and set, I haven’t plugged any Input Mapping Context on my Common Activatable Widget so I’m quite surprised it’s even working in the first place. It must be Unreal’s default UI navigation system.
I’ve tried this afternoon to plug an Input Mapping Context in those widgets but the problem remains the same, I can’t see my D-Pad or A input.
your menu should start with with a Common Widget. that CommonWidget will contain a WidgetStack and otherwise be basically blank other than some appearances and containers (borders, h-boxes, grids, and an actionbar). You will push your activatable widgets onto that stack in the main CommonWidget. You will not put a new WidgetStack on every activatable. all the activatables go into the main CommonWidget’s WidgetStack. The WidgetStack will control opening and closing the activatables. I believe the other person is right in saying you have multiple widgets open at once. you’re pressing A and its not resetting the slider, its pressing the Options button on the first activatable widget, and opening a whole new activatable that has the slider in the default position overtop of the existing one.
If that doesnt fix it then its an issue with your logic in the widgets regarding the slider. which you haven’t shown us. Sliders are very basic components and require extra logic to make functional. (ie, saving the value and applying it where necessary)
My question is how did you get the slider to work with d-pad left and right? I’ve done it myself before but I wasn’t quite happy with the way I did it.
Thanks for your answer!
I never thought about using a Widget Stack at all, I’ll try to build my menu again with it and see how it goes !
For the fact that the slider is reset at the center of the screen, it’s not because I’m pressing the Option Button on another widget. I’ve break in the code to see where it came from and it’s because of FAnalogCursor::HandleKeyDownEvent that handle pressing the A button like a mouse click.
When you click on a Slider with your mouse, the Slider goes directly to your click’s location and change the Slider’s value. Since pressing A is handled like a mouse click, and since using a gamepad is like having the mouse at the center of your screen, it simply put my Slider to the middle Value.
But I haven’t found any way yet to avoid that, and I’m not confident on the fact that using a Widget Stack will help me to solve this, it looks more like an Input issue tu me
And for working with D-Pad left and right, I simply haven’t touched at all at the Common UI Input so I’m assuming I’m using the defaults one.
Yeah, I’ve tried to put it on the right. And when I’ve clicked on it, the slider went to the left, as closest as possible to the screen center.
This problem is really comming from the Analog Controller.
I wasn’t able to work in it since the last time I’ve posted here, but I’ll probably try to catch all of the inputs and edit the slider in code by myself.