SearchField for iOS?

I plan to use a SearchField for a database app on iOS, similar to what is available for filtering tables, or as we can see in Mail:

Has anyone created such control or has a sample project with declares?

Hi @Oliver_Osswald,

look at this Feedback Case: <https://xojo.com/issue/62395>. @Greg_O attached a sample implementation to do this :wink: The SearchField is already available. You have to set AllowSearch to True for the iOSMobileTable control.

Unfortunately Xojo does not support adding a search field if there is no table. There are many cases when one needs a search field and no table.
I have not found a solution for this for the moment :slightly_frowning_face:

@Jeremie_L, how about a MobileContainer with a MobileTextField and MobileImageViewer? You could draw the Magnifier Symbol using Picture.SystemImage.

Back in 2016 @Ulrich_Bogun released a kit which seems to be obsolete now:

Is this still feasible, to do it as he did at that time?

IOSKit has UISearchbar and UISearchController. Example view with them is here: iOSKit/MissingControlsView.xojo_code at master · kingj5/iOSKit · GitHub

Is there a way to attach the UISearchBar to the navigation view?
That is what I need when displaying data with a scrollview or collection view instead of using a MobileTable.

I’m looking to add the search feature to my collection view solution…

2 Likes

Should be possible with a few declares. Maybe based on this? swift - iOS 11 UISearchBar in UINavigationBar - Stack Overflow

For now I am just using a textfield, which shows a clear-button as soon some content has been typed in.

Is the a way to catch the event when a user hits this :negative_squared_cross_mark: element, inside the textfield?

The TextChanged event will fire when that button is pressed.
You can guess the button was pressed if TextField.Text.isEmpty = True

1 Like

Thanks Jeremie, that’s exactly what I’ve been doing so far.

Thanks Jason.
With the link you provided, I was able to update iOSKit with a working example.

@Antonio_Rinaldi Adding search feature to your collection view is not important anymore as I found a valid workaround.

1 Like

Great. PR is merged now

2 Likes

Thanks to Jeremie I can use this searchbar example now, and it works on my iphone.

Now instead of catching the textchanged event, I would rather handle the search when the search button of the keyboard is hit by the user.

How would I catch this event (searchbutton pushed)?

My test project:

Based on the sample code of Jeremie in iOSKit, I found a way to search only when the user hits the search button:

AddHandler scb.SearchButtonPressed, AddressOf handle_SearchButtonPressed

plus this line in the closing event handler:

RemoveHandler searchbar.SearchButtonPressed, AddressOf handle_SearchButtonPressed

I added a string property searchtext to the screen and in the SearchTextChanged method I assign the ‘value’ to this property. Then in the SearchTextButtonPressed method, I can now do the database search only when the user hits the search button.

2 Likes