Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCocoa/Addressbook/Addressbook Notifications
Required plugins for this example: MBS MacBase Plugin, MBS MacCocoa Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCocoa/Addressbook/Addressbook Notifications
This example is the version from Tue, 30th Jul 2012.
Project "Addressbook Notifications.rbp"
Filetype text
End FileTypes
Class MainWindow Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
EventHandler Sub Open() // First, open the addressbook book=new MyABAddressbookMBS End EventHandler
Property Private book As ABAddressbookMBS
End Class
MenuBar MenuBar1
MenuItem UntitledMenu1 = ""
MenuItem FileMenu = "&File"
MenuItem FileQuit = "Quit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu0 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
End MenuBar
Class App Inherits Application
EventHandler Sub Open() if TargetMachO=false then MsgBox "This example needs a MachO target running on Mac OS X." quit end if End EventHandler
End Class
Class MyABAddressbookMBS Inherits ABAddressBookMBS
EventHandler Sub DatabaseChanged(Externally as boolean, InsertedRecords() as string, UpdatedRecords() as string, DeletedRecords() as string) dim l as listbox l=MainWindow.List if Externally then l.AddRow "DatabaseChanged externally" else l.AddRow "DatabaseChanged internally" end if l.AddRow "InsertedRecords:" ShowArray(InsertedRecords,l) l.AddRow "UpdatedRecords:" ShowArray(UpdatedRecords,l) l.AddRow "DeletedRecords:" ShowArray(DeletedRecords,l) l.ListIndex=l.LastIndex End EventHandler
Protected Sub ShowArray(a() as string, l as listbox) for each s as string in a l.AddRow s dim r as ABRecordMBS = self.recordForUniqueId(s) if r isa ABPersonMBS then dim p as ABPersonMBS = ABPersonMBS(r) dim firstname as string = p.valueForProperty(self.kABFirstNameProperty) dim lastname as string = p.valueForProperty(self.kABLastNameProperty) l.AddRow firstname+" "+lastname elseif r isa ABGroupMBS then dim g as ABGroupMBS = ABGroupMBS(r) dim name as string = g.valueForProperty(self.kABGroupNameProperty) l.AddRow name end if next End Sub
End Class
End Project

See also:

Feedback, Comments & Corrections

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

MBS Xojo Plugins