Restricted ComboBox

As a result of another thread, I made a subclass of the Combobox, you can only type something if it matches an item inside the combobox list.

See here: https://github.com/Carharttguy/xojo-RestrictedComboBox

It’s only a start I made in half an hour. It’s not the best code you’ll ever read, and it’s not nearly finished.
Report errors etc, I might work on it this weekend if there is interest.

You’re going to make me say it again, aren’t you.

[quote=309598:@Tim Parnell]
The point of a ComboBox is to offer a combination of TextField and PopupMenu. It allows you as a developer to provide a list of common examples that could save the user time, but allows them to fill in a value you might not have accounted for.

By not allowing them to enter their own value, you’re tossing out the purpose of the control.[/quote]

I appreciate the work you’ve put in to try to help the community, but it creates a very poor user experience to circumvent the expectations of the control.

I replied in the other thread, I simply don’t agree with that opinion. Controls don’t define user experience, it’s the other way around.

Basic controls that have been around for years have expected use cases.
When you see a button, you know to click it to do something.
When you see a TabPanel, you know that each panel has a different view.
When you see a PopupMenu that is closed, you know what it’s going to look like when you click it - and that you’ll have to select something once you do.

The standard expectation for a ComboBox is that if it doesn’t have the value listed, you can type in your own.

A good UI leads to good UX and a happier User.

It leads to consistent UI expectations from one app to another which increases peoples transfer of learning from one app to another

This is a good thing

Making a combobox be a restricted list is basically a popup menu that supports type ahead.

Tim, relax.

I for one am curious to see how he wants to do it with the KeyDown event :wink:

:o

Had a look at your example.

First thing that comes to mind: It is a good idea to start the design with pen and paper. Make a list of the abilities you want your control to have. What to look out for. Don’t start by jumping in and putting the first rough draft out.

Secondly: add other controls on your window. It is not a good test if you check your input control in isolation. People jump to other controls on purpose or by accident. You need to account for that.

Thirdly: At the moment you can only add numbers from 0 to 99999. You could have reached the same level of functionality as your example by putting in a textfield and setting its mask to #####

Fourthly: it’s not working properly. See the example I gave in the other thread (I added Anna and Anne as entries, added a TextField, typed An in your ComboBox, and clicked on the TextField).

Fifthly: trust me. You won’t be able to do it all with the keyDown event.

It’s also not a good idea to make a new identical thread. It makes it seem that you don’t like what has been said in the first one so you open another. Basically that you are looking for validation or glory. But the point here is that you ask for opinions and people give them. They spend time and effort dealing with what you say. Maybe you’ll better ask them why they think this or that, rather than come up with something silly like “Controls don’t make user experience. It’s the ther way round”. That’s just BS.

I also don’t think it is a good idea to put the project in its current state on GitHub, but maybe that’s just me.

I would be interested in a combobox subclass that autocomplete works right for Windows. I have had limited success trying to work around the issues listed in this topic.

Basically it would be nice if the user could type the first few letters and have the rest actually autocomplete when tabbing on to the next field.

Better use Mike Cotrone’s class.

[quote=309691:@Norman Palardy]
Making a combobox be a restricted list is basically a popup menu that supports type ahead.[/quote]

A couple decades or so back I used a VAX based product with a VT100 UI that used that approach extensively… Can be very useful in certain situations with long lists.

  • Karen

Decades ago I wrote such a thing on a VAX system for VT220’s :stuck_out_tongue:

[quote=309702:@Markus Winter]Had a look at your example.
…
I also don’t think it is a good idea to put the project in its current state on GitHub, but maybe that’s just me.[/quote]

I now know what bothers me about this project on GitHub: the project does not fulfil the description at all:

[quote]A ComboBox where you can only type something that corresponds with the list

The ComboBox updates it contents if you type something that is a match within the list. This subclass can be used as a drop in. Only the AddRows is NOT useable as I needed it and made it protected.[/quote]

You are raising expectations without fulfilling them: The project does not work with any given list, ONLY with lists where every possible entry is covered (e.g. ALL numbers from 0 to 99,999). It can’t be used as a drop-in replacement. It doesn’t work well with other controls.

Sorry to be so harsh now but: Xojo makes it easy to program. Unfortunately it also allows people to quickly put out poor code that works after a fashion, but falls over otherwise. Resulting in a bad reputation for both the programmer and Xojo.

You have some very talented and experienced programmers at your disposal here, who have shown a willingness to help.

Think about where the potential problems with your example are. Then have a look at Mike’s class. Look at how he deals with the problems. Ask here if you do not understand something. If you understand his code, and why he did the way he did it, then you have made progress.

I still remember that I looked for years at Joe Strout’s DrawPic example and couldn’t figure out how he managed to do what he did with so little code - and I didn’t get the code at all. Everyone starts like that. Even experienced people who start on something new (just because someone is an ace in databases doesn’t mean he knows much about graphics).

Maybe it works better on Mac than windows?

I know it’s an open source control and probably very good at what it does. Here are a few things that make it feel not native on windows.

  1. No drop down button.
  2. Drop down list is confined to parent window.
  3. Tabbing to another field doesn’t hide the dropdown list. (this leads to exceptions)
  4. Using the arrow keys to highlight an item works but pressing enter has no effect.
  5. Hovering over the control gives it the focus

There are probably more, and I’m not in anyway criticizing Mike by this. The readme clearly states that it was tested only on Mac.

I would have sub classed combo box long ago if the selstart/sellength wouldn’t be broke. <https://xojo.com/issue/45959>

I would not try to subclass. The regular combobox is way too limited.

I would use a TextField as to have all features, stick a picture of the drop down button on the right in a canvas.

If you use a simple Listbox for the dropdown, you cannot display below the window. You will have to explore a solution based on a plain box window if you want it to extend below or above the parent window.

You basically answered my question in the new thread I just started. Yes using a plain box window is the correct approach for the dropdown. I did this with my custom date picker. I might just subclass a combobox with autocomplete off. I would need to handle the dropdown list entirely myself.

[quote=309762:@Michel Bujardet]I would not try to subclass. The regular combobox is way too limited.[/quote] Actually I would.

My date picker is actually a subclass of combobox! I would like do something similar for combobox when I have time.

I am impressed. I did not even suspect such a thing could be done with ComboBox. Apparently you have solved the SelStart and SelLen issue in your date picker.

To clarify… SelStart/SelLen is only broke when AutoComplete is on. This forces me to implement my own dropdown list if I subclass ComboBox. I essence it forces me to ‘do it right’ rather than patching existing functionality.

Workarounds are the essence of powerful programming :wink: