TextEditor + PopupMenu + Auto completion

Hello Jules and the ROLI team !

I have a feature request. I wanted to create a TextEditor which displays a PopupMenu when you start to write something, with suggestions based on what you have written. This is something very common on web apps. However, it is tricky to do that with JUCE, even if I have been able to see a few posts on the JUCE forum about this issue from a long time.

Howver I have succeeded by creating a custom PopupMenu which takes as a parameter a KeyListener in its showMenuAsync / showWithOptionalCallback. I use then this KeyListener to redirect key events into my Text Editor if the key pressed is not up/down arrows, return or escape.

Would it be possible to add a showMenu function in the PopupMenu class which takes the KeyListener as a parameter, and attach to the window, so I won't need a hack anymore for this ? Or maybe, add finally a well written JUCE component for this important functionnality, which has been asked several times here ? ;)

Thanks in advance !


Can’t you simply have a TextEditor which has a PopupMenu and have a TextEditor::Listener and respond to textEditorTextChanged() and update the PopupMenu ?

I’ve done that using a TextEditor and a ListBox.


Well the tricky part is the fact that the PopupMenu that you can display when the textEditorTextChanged() event occured has a modal state. So, it takes the keyboard focus from the TextEditor (for navigation into its entries) and gives it back only when it disappears. The solution for me was to send to the TextEditor some KeyPress events the PopupMenu gets.

If you have any solution which is less painful to use, I will gladly try it ;) I have to confess I don't use that much ListBoxes, and using a PopupMenu seemed logical to me.