Cannot interact with list box when focused with arrow keys


#1

So, I managed to get the GUINavGroup working successfully (after posting about it on the github issues before being redirected here for future issues I had). It works so far… accept for the fact that I can’t select anything in the list box when its focused. I’m visually impaired, so this is pretty important to me. If this functionality isn’t possible I can just utilize buttons, though I’d love a cleaner interface like a list box. I thru together a crappy global input event handler:

gInput().onButtonUp.connect([&](const ButtonEvent& event) {
switch(event.buttonCode) {
case BC_UP: {
if (listFocused) {
if (selected<0) {
selected=0;
options->selectElement(selected);
} else {
--selected;
options->selectElement(selected);
}
}
}
break;
case BC_DOWN: {
if (listFocused) {
if (selected>opts.size()) {
selected=opts.size();
options->selectElement(selected);
} else {
++selected;
options->selectElement(selected);
}
}
}
break;
default:
break;
}
});

The problem with this is that it doesn’t fully work. I can select the first two options, but not the rest. Plus, this isn’t ideal; I’d like to be able to have a private input handler just for this. I’ve also got another global input event handler for page up and page down to turn the background music up and down by 0.1; I wonder if that’s interfering with it. Either way, another caveat to this is that its slow. It takes about 90 MS to select an item. Maybe its me but this seems a bit sluggish; I’d prefer snappy selection. :slight_smile:
So, my overall question is: is there an option, or some kind of flag, that I can implement to make it possible for other things (other than the mouse) to be able to select items in the list box when its focused? Do I need to set an option upon creation?


#2

If you hit Enter to open the list box drop down, and then use the arrow keys it should work. But it would be nice to be able to use the arrow selection without opening the list box, I’ll add that at some point.

I’m not sure why would it be so slow, GUI updates aren’t the fastest thing but 90ms is way too long. Do you notice slowdowns with other GUI elements as well? (e.g. inputting text in a text box and similar)


#3

Nope. That was just with my custom key handler. I’ll remove it and try what you suggested.
Trying it now…
OK, that works. The problem is that I have to press enter to close the list box, and then the selected event fires, rather than it being fired as soon as the selection actually changes. Would I need to create a drop down instead of a list box for this to actually happen?


#4

I don’t think there’s a way to do what you need without extending how GUIListBox works. Either by adding functionality to switch selection simply by using the arrow keys, or by adding another event callback for when list selection highlight moved, without confirming the selection.


#5

So not even a drop down would do the job? I’m implementing a general TTS library right now to work with Speech Dispatcher on Linux, Mac OS, BSD, … as well as Tolk on windows, and then I’ll see about switching to drop downs, if you feel that would be the better way to go. I’ve tried compiling the latest unstable (git hub) release of BSF (I tried it yesterday in fact) and MSVC gave me a bunch of linker mismatch errors when trying to compile in Debug mode, so I have to stick to binary releases, sadly. I’d go with Release builds too (which I’m doing now), but Debug is nice to have sometimes.


#6

I’m not sure what drop down element are you referring to, technically a list box is a drop down. The easiest option is really to extend the list box code. Or you could just build a GUI element of your own from the ground up, since the system is extensible.

I’m not sure why MSVC is giving you trouble, make sure to compile 64-bit as I don’t provide precompiled dependencies for 32-bit builds.


#7

I do build for 64-bit. I open Visual Studio 2017->Visual Studio Tools->VC->x64 Native Tools Command Prompt for VS 2017. It gave me mismatch errors when I last ran it.


#8

Update: I’ll probably end up just extending the GUI List Box component to add that event. I’ll send in a PR, if you accept PRs, once I’ve beta-tested it (and can get it to actually compile). :slightly_smiling_face: :slight_smile:Edit: I can’t figure it out. Sad. You’ll have to do it; I’ve never modified the GUI system like that.