SpotlightQuery.Query
From Xojo Documentation
Property (As String )
This property is only available on the macOS platform. For cross-platform compatibility, use #If...#Endif with the Target... specifiers to make sure you will not attempt to use this property on an incompatible platform. |
aSpotlightQuery.Query = newStringValue
or
StringValue = aSpotlightQuery.Query
Supported for all project types and targets.
or
StringValue = aSpotlightQuery.Query
Supported for all project types and targets.
The query string that will be passed to the Spotlight engine.
Notes
You search on the metadata attribute keys provided by Apple using their format. See the notes for the format of the query.
Example
The following asynchronous query uses the search string that the user enters into a TextField and displays the filename and its absolute path in a Listbox. It uses a SpotlightQuery control named "Query" that has been added to the window.
First, add the following method "UpdateList" to the window:
Sub UpdateList()
ListBox1.RemoveAllRows
Query.Pause
For i As Integer = 0 To Query.Count - 1
ListBox1.AddRow(Query.Item(i).File.DisplayName)
ListBox1.CellValueAt(ListBox1.LastAddedRowIndex, 1) = Query.Item(i).File.NativePath
Next
Query.Resume
End Sub
ListBox1.RemoveAllRows
Query.Pause
For i As Integer = 0 To Query.Count - 1
ListBox1.AddRow(Query.Item(i).File.DisplayName)
ListBox1.CellValueAt(ListBox1.LastAddedRowIndex, 1) = Query.Item(i).File.NativePath
Next
Query.Resume
End Sub
In the SpotLightQuery's Changed and Completed event handlers, call the UpdateList method.
In a PushButton, enter the following code in its Action event handler.