emilk / egui

egui: an easy-to-use immediate mode GUI in Rust that runs on both web and native
https://www.egui.rs/
Apache License 2.0
21.79k stars 1.57k forks source link

Add an editable combobox, possibly rename the existing to "dropdown" #2382

Open flxzt opened 1 year ago

flxzt commented 1 year ago

Is your feature request related to a problem? Please describe.

Currently the widget named combobox is implemented as what other UI toolkits would describe as a dropdown or dropmenu. Usually a combobox is a combination of a text edit and a dropdown with a lsit of entries that replace the content when selected. see wikipedia.

Describe the solution you'd like I think renaming the existing combobox widget to dropdown and creating a new one with an editable text field would match user expectations better and would add a new very useful and classic widget to the toolkit.

Describe alternatives you've considered

I tried using a simple text field next to the current combobox widget, but since you cannot only display the arrow button it is awkward because it always expands to the width of the selectable entries. See:

Bildschirmfoto vom 2022-12-04 18-41-59

tomasz-wiszkowski commented 6 months ago

I wrote a simple component that aims to do this exact thing; what baffles me the most is that I have to call request_focus() on each frame, otherwise my editor is not accepting any input.

the result of me calling request_focus() is that the CPU utilization spikes to (at best) 40%, which is unfortunately unacceptable: embedding a TextEdit within the ComboBox dropdown to allow filtering items works, but appears to be a bad idea (I filter my items only when filter value changes; even 3 items on the list keep my CPU at 40% utilization).

I'll see if I can build a performant variant of this; if I succeed, I'll make a pull request.

ThePuzzlemaker commented 5 months ago

@tomasz-wiszkowski How's it going?

tomasz-wiszkowski commented 5 months ago

Mixed results TBH, but after some time working with egui I begin to think this may be linked to design decisions.

Getting editable combo box to work is not a big problem. Getting it to work well - is.

image

showing this can consume even 10% of the CPU. Even more if you move mouse.