Textfield in a popup menu?

Apologies if this has been covered before…can’t find anything using forum search.
I’m hoping it’s possible to add a textfield to a popup menu (ie: internet search box). Or is there some way I can configure a combobox to do this? I already have things set up in my popup to open my default browser at a few different url’s, I’d just like to have a search field that will do the same, but will auto-add search terms when the browser opens at DuckDuckGo (the formatted url string is also not an issue). I’d prefer not to use htmlviewer.
Thanks for your time. :slight_smile:

Search for ComboBox…

I’m familiar with comboboxes, and did search as suggested. Still unable to find anything that will let me use the CB’s text entry as browser search terms. Am I missing something obvious?

I do not understand your question.

Please explain.

IMHO:
ComboBox = PopupMenu + TextField.

Now, if you want the full search feature, (1) you have to code it by yourself.

(1) the popupMenu part of the ComboBox automatically populated by entries related to the text you are writing…

  1. Using either a combobox or popup menu, I want to have some sort of text entry field where I can enter DuckDuckGo search terms.
  2. I would then like it to open my default browser (Firefox) at DuckDuckGo with the search terms already implemented and results showing. (this part is easy and already known to me).

It’s making a combobox entry do something OTHER than search its own rows that I’m puzzled about.

Yes, you miss the point !

Once yu entered text in the TextField, you press Return (or Enter) and YOUR CODE DO THE SEARCH.

The Documentation entry for ComboBox is here:
https://documentation.xojo.com/api/user_interface/desktop/desktopcombobox.html

Understood. Didn’t know comboboxes can work like that. I’ll figure it out. Thanks for your time.

I still do not understand…

An implementation example:
In a window where people get information to lead to a meeting, there is a ComboBox that allows to set who send the customer.
I fill a ComboBox with a list of know companies and the TextField is used in case the company is new to us…

Is it clear for you ?

Clear. The thing I didn’t previously know is that the CB textfield can be used for functions other than searching its own rows and showing matching (selectable) row entries.

Same here (but inverted: I never think this can be used to search something in the PopupMenu Part…) :grinning:

NB: on PopupMenu, typing a letter shows the first word that starts with this letter ON WINDOWS…
On MacOS, typing fr leads to France… (and goes to the r entry if you do that on Windows…)
How strange !

That is so bizarre! Good info to know. Thanks for making sure my head is screwed on right, Emile. I think I’m good from here. :smiley:

1 Like

Just for future reference, and for floundering hobbyists like myself, here’s what I used that works.
NOTE: Originally, opening my default browser at any pre-defined URL would cause my Xojo app to freeze until the browser was closed. Also, I aborted using htmlviewer to view desired web sites since I couldn’t find a way to incorporate any sort of adblock…besides, I hate Safari. :wink: I found this “ext://” workaround somewhere on these forums, and it solves the app-freeze problem. “fontswin.viewer” is a 100x100 htmlviewer that acts strictly as a sort of relay to firefox (I think). I’m sure this is clunky, but here goes…

Combobox keydown event:

If Key = Chr(13)  then  // "enter" key was pressed
  
  if me.Text <> "" then  // combobox textfield isn't empty
    var formatstr as string
    
    formatstr = me.Text
    formatstr = formatstr.ReplaceAll(" ", "+")  // format search terms for DuckDuckGo
    formatstr = "ext://duckduckgo.com/?q="+formatstr+"&t=h_&ia=web"  // final DuckDuckGo URL
    
   if nthfield( formatstr, ":", 1 ) = "ext" then  // I have no idea why this section is required, but it works
      ShowURL(replace( formatstr, "ext://", "https://"))
    end if
    
    fontswin.viewer.LoadURL(formatstr)
    fontswin.close()
    me.SelectedRowIndex = -1  // set combobox back to blank textfield
    
  end if
  end if

Please, note:
Enter: Chr(3)
Return: Chr(13)

Should I use both then? Chr(13) works on Linux.

Yes, you should. Otherwise only one (Enter or Return) will work, on Mac (which distinguishes these two keys, unlike Windows (and possibly Linux)).

My app is solely for my own use on Linux, but I appreciate the advice for future use and will get in the habit of using both. Thanks a pantload. :slight_smile: