Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/MacOSX/Spotlight/Search all applications in applications folder
Function:
Required plugins for this example: MBS MacOSX Plugin, MBS Picture Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacOSX/Spotlight/Search all applications in applications folder
This example is the version from Thu, 6th Apr 2016.
Project "Search all applications in applications folder.rbp"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class MainWindow Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
EventHandler Sub Open() List.ColumnAlignmentOffset(0)=20 End EventHandler
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control UpdateTimer Inherits Timer
ControlInstance UpdateTimer Inherits Timer
EventHandler Sub Action() MainWindow.List.DeleteAllRows dim items() as MDItemMBS = q.Results for each it as MDItemMBS in items AddItem it next Title = str(UBound(items)+1)+" items" End EventHandler
End Control
EventHandler Sub Close() if q<>nil then q.stop q=nil end if End EventHandler
EventHandler Sub Open() q=new MyQuery("kMDItemContentType=""com.apple.application-bundle""") if q.Handle=0 then MsgBox "Failed to create query" else dim appfolder as FolderItem = SpecialFolder.Applications dim paths(-1) as FolderItem dim options(-1) as string paths.Append appfolder q.SetSearchScope(paths, options) if q.Execute(q.kMDQueryWantsUpdates) then 'ok q.EnableUpdates else MsgBox "Failed to run query" end if end if End EventHandler
Sub AddItem(it as MDItemMBS) dim file as FolderItem = GetFolderItem(it.Path, folderitem.PathTypeShell) List.AddRow it.DisplayName List.RowPicture(list.LastIndex)=file.IconMBS(16) Exception e End Sub
Property q As MyQuery
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
Class MyQuery Inherits MDQueryMBS
EventHandler Sub Finish() MainWindow.UpdateTimer.Mode = 1 End EventHandler
EventHandler Sub Progress(AddedItems() as MDItemMBS, ChangedItems() as MDItemMBS, RemovedItems() as MDItemMBS) MainWindow.UpdateTimer.Mode = 1 End EventHandler
EventHandler Sub Update(AddedItems() as MDItemMBS, ChangedItems() as MDItemMBS, RemovedItems() as MDItemMBS) MainWindow.UpdateTimer.Mode = 1 End EventHandler
End Class
End Project

See also:

Feedback, Comments & Corrections

The items on this page are in the following plugins: MBS MacOSX Plugin.




Links
MBS Xojo tutorial videos