Good evening, first of all with the focused and unFocused events the problems of making widgets with gampad or keyboard would be solved very much.
I’ve been a programmer for some time (Delphi, java, c ++ … = but it’s the first time I’ve programmed a videogame and use unreal engine 4.18.
After a lot of reading through forums and not getting much … I have come up with a solution that I think is elegant that I am using (until we have the onFocus and onUnFocus events) and I wanted to share it with you …
The code consists of the following_
Step 1: I enter manually All widget buttons in an array in the begin play event
In my case they are always inside a vertical box
Note: I do not think there is an array with all the elements of the widget, it’s a pity because it would be very useful
Step 2: In a tick event I use a loop I check if the button is focused with a branch.
If this focus changed the normal style “imitating” hovered and if it is not, change to normal style
Step3: To not have the sound in loop I use a doOnce event that is reset each time the style is changed to focused with the variable focused
The integer variable “focused” saves the last element “focused”, if the variable changes, it resets the doOnce function
Note1: The UnFocusButton function is simple because my buttons are transparent
Note2: I’m sorry for my english … it’s very bad
Buenas noches, antes de nada con los eventos focused y unFocused se solucionaría mucho los problemas de hacer widgets con gampad o teclado.
Soy programador desde hace tiempo (Delphi, java, c++…= pero es la primera vez que programo un videojuego y uso unreal engine 4.18.
Después de mucho leer por foros y no conseguir gran cosa… he llegado a una solución que me parece elegante que estoy utilizando (hasta que tengamos los eventos onFocus y onUnFocus) y quería compartirla con vosotros…
El código consiste en lo siguiente_
Paso 1: Introduzco manualmente Todos los botones del widget en un array en el evento begin play
En mi caso están siempre dentro de un vertical box
PD: Creo que no existe un array con todos los elementos del widget, es una lastima porque seria de gran utilidad
Paso 2: En un evento tick utilizo un loop compruebo si el boton esta focused con una rama.
Si esta focused cambio el estilo normal “imitando” hovered y si no lo esta, cambio a stilo normal
Paso3: Para no tener el sonido en loop utilizo un evento doOnce que es reseteado cada vez que cambia el estilo a focused con la variable focused
La variable integer “focused” guarda el ultimo elemento “focused”, si la variable cambia, resetea la funcion doOnce
PD1: La funncion UnFocusButton es simple porque mis botones son transparentes
PD2: I’ m sorry por mi ingles… es muy malo