Platforms to show: All Mac Windows Linux Cross-Platform
/MacOSX/Disk Arbitration/Events
Required plugins for this example: MBS MacOSX Plugin, MBS MacCF Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacOSX/Disk Arbitration/Events
This example is the version from Sat, 10th May 2013.
Project "Events.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub Open()
session = new MyDASessionMBS
End EventHandler
Property session As MyDASessionMBS
End Class
Class Window1 Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
EventHandler Sub Change()
PList.DeleteAllRows
if me.ListIndex = -1 then
// nothing
else
dim dic as Dictionary = me.RowTag(me.ListIndex)
for each key as Variant in dic.keys
dim value as Variant = dic.Value(key)
if value isa FolderItem then
dim f as FolderItem = value
value = f.UnixpathMBS
end if
if value isa Dictionary then
value = "<dictionary>"
end if
if value isa CFUUIDMBS then
dim u as CFUUIDMBS = value
value = u.StringValue
end if
PList.AddRow key, value
next
end if
End EventHandler
End Control
Control PList Inherits Listbox
ControlInstance PList Inherits Listbox
End Control
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 MyDASessionMBS Inherits DASessionMBS
EventHandler Sub Appeared(disk as DADiskMBS)
dim dic as Dictionary = disk.Description
dim name as string = getname(dic, disk)
log "Disk appeared: "+name, dic
End EventHandler
EventHandler Sub DescriptionChanged(disk as DADiskMBS, keys() as string)
dim dic as Dictionary = disk.Description
dim name as string = getname(dic, disk)
log "Disk description changed for "+name, dic
Break
End EventHandler
EventHandler Sub Disappeared(disk as DADiskMBS)
dim dic as Dictionary = disk.Description
dim name as string = getname(dic, disk)
log "Disk disappeared: "+name, dic
End EventHandler
EventHandler Sub Peek(disk as DADiskMBS)
dim dic as Dictionary = disk.Description
dim name as string = getname(dic, disk)
log "Disk peek: "+name, dic
break
End EventHandler
Function getname(dic as Dictionary, disk as DADiskMBS) As string
if dic.HasKey(DADiskMBS.kDADiskDescriptionVolumeNameKey) then
Return dic.Value(DADiskMBS.kDADiskDescriptionVolumeNameKey)
end if
if dic.HasKey(DADiskMBS.kDADiskDescriptionMediaNameKey) then
Return dic.Value(DADiskMBS.kDADiskDescriptionMediaNameKey)
end if
if dic.HasKey(DADiskMBS.kDADiskDescriptionDevicePathKey) then
Return dic.Value(DADiskMBS.kDADiskDescriptionDevicePathKey)
end if
if dic.HasKey(DADiskMBS.kDADiskDescriptionVolumeNameKey) then
Return dic.Value(DADiskMBS.kDADiskDescriptionVolumeNameKey)
end if
if dic.HasKey(DADiskMBS.kDADiskDescriptionVolumePathKey) then
dim n as folderitem = dic.Value(DADiskMBS.kDADiskDescriptionVolumePathKey)
return n.Name
end if
Return disk.BSDName
End Function
Sub log(Message as string, dic as Dictionary = nil)
dim d as new date
dim l as listbox = window1.List
l.AddRow d.ShortTime, message
l.ScrollPosition = l.LastIndex
l.RowTag(l.LastIndex) = dic
End Sub
End Class
End Project
See also:
The items on this page are in the following plugins: MBS MacOSX Plugin.