I’ve added a Search Field to a Web project. Works fine, but what I’d like to have is a little “x” at the end so that the contents of the field can easily be cleared - pretty common UI for this kind of thing.
It should be possible to get most recent browsers to add the “x” automatically, by using “type=search” to the HTML that’s used to display the field - see http://www.html5tutorial.info/html5-search.php. I’ve had a look at the HTML that Xojo generates for a WebSearchField, and it uses type=text instead of type=search. There doesn’t seem to be any obvious way to change this.
I can work around this by overlaying a canvas over the top of the search field, drawing an “x” icon on it, and using the MouseUp event to simulate a button (and no doubt there are other things that can be done with CSS/JavaScript). This works, but isn’t ideal.
Is there a good reason why Xojo should use “type=text” for WebSearchFields, am I missing something, or is this a feature request job?
What browser are you using? What Xojo version are you using?
I just did a little test project in 2016r3, and the search field is indeed type=“search”
In Safari, I see the X you wish to accomplish.
Weirdly, if you try to set a TextField to type=“search” using Javascript in the Shown event it doesn’t have either the magnifying glass icon, nor the X in Safari. It does change shape though.
Well, that’s bizarre! I too am using Xojo 2016r3, but on Windows rather than Mac. If I drag a totally standard WebSearchField onto a Web page in a brand sparkly new project, the HTML I see for it is:
I’ve looked at it with Chrome, IE11, and Edge - all on Windows 10. Interestingly, IE and Edge do display the “x” even though I can confirm with their respective Developer Tools that the line of HTML they’re rendering is indeed as above with type=“text”. It’s only Chrome that doesn’t play ball. If I use Chrome’s Developer Tools to tweak the HTML so that type=“search”, Chrome adds the “x” too, but the height of the field decreases.
What happens when you build a Web app on a Mac, and then connect to it with a Windows browser? How do the search fields display, given that the Mac-built Web app is producing different code for the browser to render?
It has nothing to do with where the app was built. The control HTML is built for the browser at runtime. You see the best representation for the user agent presented. As features evolve, sometimes that representation needs to change.
If you are serious about making sure your app looks good in all browsers, you should consider having an emulator installed to check how it looks under other systems. I use VMWare Fusion on Mac, but you can also download VirtualBox.
The problem is that if you build a Xojo Web project on Mac, you get different HTML code to when you build the same project on Xojo for Windows - check out earlier in the conversation.
At any rate you want to make sure your app behaves correctly under all current platforms. Incidentally, that includes not only Mac, but especially Android and iOS.
Yes, I’d misunderstood. Tim P got a different result not because he’d compiled the project on a Mac, but because he was using a Mac browser. That makes much more sense.
Thanks all - I’ll go ahead and create that feature request.