I see the documentation for WebSearchField mentions that “…it does provide a recent searches popup menu of values that were recently entered by the user.” However, I don’t see how to implement this - I assumed it was a built-in behavior, and that I could enable/disable it if needed, but I don’t see any reference to it in the docs. Anyone have any experience with this?
Yes, it is a browser-level feature handled when you set an input
control to type="search"
. Keep in mind that means it doesn’t apply to everyone, only browsers that support it.
Hi @Tim_Parnell , strangely this control doesn’t appear to display past entries in any of my (3) test browsers, which makes me wonder if an entry has to be ‘committed’ with the Pressed button(?). Or do I need to add a Style for ‘type=“search”’ to the Opening Event of the control…?
No, this is what the Xojo Web framework does for you when you use WebSearchField.
That would seem reasonable. Pressing the Enter/Return key should suffice though. This would be worth testing if you’re having trouble (before filing a Ticket).
I’m very slow to file any tickets, as many bugs tend to be “me” and not bugs after all
While I have you, it seems you are pretty familiar with the WebSearchField, so I hope you don’t mind if I populate this posting with a few quick follow-on questions; these are always helpful for the next person who stumbles on this.
I’m using Xojo 2024 4.1, and want a good way to display the (found) results of WebSearchField. It doesn’t appear that ContextualMenu works with this control (although the docs say it does). How would you display the list of found results, in an elegant way? Is the WebPopupMenu an option? I’m defaulting to using a simple WebListBox, but that takes up a lot of screen space, and doesn’t appear very modern to users. Any suggestions are appreciated.
I believe it does require the user to press return or the search button. Otherwise it would store an item on every keypress and the history would look like this:
H
He
Hel
Hell
Hello
The design I generally use can be found in the output of ARGen.
I provide a full list of the whole results with a filter field. When the user performs a search, it filters the list as necessary. It can be done with WebDataSource and TextChanged events for a near-live search of a table. Again, the example is in ARGen.
It seems nobody has updated the ARGen project for the changes to the WebDataSource interface so you may have some things to figure out to get a demo project running. However, even in it’s “doesn’t work out of the box” state, it still is a great starting point.
If you want to test how this works/looks, you can visit:
using FireFox and do a couple of searches, after that you can see this when you click inside the search field:
I had to click Submit for the search to be added to the list.
I was not able to reproduce this with Chrome.
Agreed! Which raises another point: The Pressed event triggers when you press Return, click the Magnifying Glass, AND when you click the ‘x’ to clear contents. From what I can tell the event doesn’t pass anything to tell you which of the three events took place, so Pressed might not be the determining factor.
Yeah, that looks like a typical WebListBox, which I’m very comfortable with. I was just hoping for a better (more current) way to allow for live selecting from a virtual dropdown that occurs as search results are found.