What is "Selection Type" from Combo Box OnSelectionChanged node?

Made a combo box that is almost functional, but I am not seeing the output I expected from the “Selection Type” output on the OnSelectionChanged node. It is giving me 2 every time. even with a drop down that only has 2 items. I was hoping that it the first item in the list would be 0, the second 1, and so on but that either isn’t the case or I am running into a bug.

I would prefer not to use the Selected Item as that would force me to make the code more bloated than would be the case if I were getting an index of the selection of the dropdown. Any help would be appreciated!

if this is something the player sees in game, i recommend you roll your own combo box widget. its pretty easy to make a menu by adding custom widgets as a child of a vertical box, and you get a lot more freedom to customize things, like adding icons or separator lines or special rollover effects or greyed out choices.

You can already add widgets to the combo box, which should give the same level of control right?

Yeah, it isn’t obvious that you can do it. Only found out by reading a post by Nick Darnell where he showed how you can do it. There are a couple other posts around that also point in that direction.

For the above issue, I basically made a work around by doing a complicated branch check on all the string names I could expect, but it is less elegant than if the “Selection Type” output of the node gave the expected index of the dropdown. It only gives a value of 2, no matter which selection you make or however many selections are in the dropdown.

i didn’t know that. i haven’t played with the standard combo boxes much, because one of the first things i made in UE4 was a generic menu system that i use for any list of ui cards, and drop down functionality was designed into it. I also made my own sliders and power meters, just in case i need more control than the standard widgets.

Any dev able to comment on this node?

The Selection Type output pin outputs what type of input was used to make the selection.
For example if you use a mouse and selects the option using a mouse click it will output “On Mouse Click”.

Unfortunately you have to use SelectedItem (String). It’s the only way Unreal communicates to you what item was selected. SelectionType can not be used, it just tells you if a mouse cursor or keyboard was used to make the selection.

However you can still turn the String into an index like you want, by calling:

FindOptionIndex

This was the solution I was looking for, thank you! I populated the selections from an array, then when the player selects the drop down menu item, you translate the string that OnSelectionChanged generates into an index via Find Option Index. Worked like a charm!

FWIW, I use Selection Type to differentiate between a function loading data to the combobox on UI loading vs the player making a selection. The code can only run when a user initiates it, so a quick check filters out non-human interaction. You might wonder why “OnMouseClick” is in two formats. I discovered that when running in the editor the spaces appear, but when running a build, the spaces are gone. Neat, UE! Also, I realize that if I want to port this game to console I will need to do some testing with a controller before shipping. Happy coding!