Platforms to show: All Mac Windows Linux Cross-Platform
/Mac64bit/Contacts/CNContactPicker Test
Required plugins for this example: MBS Mac64bit Plugin, MBS MacBase Plugin, MBS MacControls Plugin, MBS MacCocoa Plugin, MBS MacCloud Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Mac64bit/Contacts/CNContactPicker Test
This example is the version from Fri, 13th May 2021.
Project "CNContactPicker Test.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open()
if ContactStore.available then
ContactStore = new CNContactStoreMBS
else
MsgBox "Please run as 64-bit Mac app."
end if
End EventHandler
Property ContactStore As CNContactStoreMBS
End Class
Class MainWindow Inherits Window
Control LogList Inherits Listbox
ControlInstance LogList Inherits Listbox
End Control
Control PickButton Inherits PushButton
ControlInstance PickButton Inherits PushButton
EventHandler Sub Action()
dim b as NSButtonMBS = me.NSButtonMBS
picker = new MyCNContactPickerMBS
dim r as new NSRectMBS(0,0,200,300)
picker.showRelativeToRect(r, b, picker.MaxXEdge)
End EventHandler
End Control
Property picker As MyCNContactPickerMBS
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class MyCNContactPickerMBS Inherits CNContactPickerMBS
EventHandler Sub DidClose()
log CurrentMethodName
End EventHandler
EventHandler Sub DidSelectContact(contact as CNContactMBS)
Log CurrentMethodName
// We requery it to get a full contact record
Dim e As NSErrorMBS
Dim c As CNContactMBS = app.ContactStore.unifiedContactWithIdentifier(contact.identifier, e)
If c = Nil Then
If e <> Nil Then
Log e.LocalizedDescription
End If
// failed?
c = contact
End If
Log "Contact: "+c.givenName + c.familyName + c.nickname
// keep for later?
Self.Current = c
End EventHandler
EventHandler Sub DidSelectContactProperty(contactProperty as CNContactPropertyMBS)
log CurrentMethodName
log "ID: "+contactProperty.Identifier
log "Key: "+contactProperty.Key
log "Label: "+contactProperty.Label
log "Value: "+contactProperty.Value.StringValue
End EventHandler
EventHandler Sub WillClose()
log CurrentMethodName
End EventHandler
Property Current As CNContactMBS
End Class
Module Module1
Sub Log(s as string)
MainWindow.LogList.AddRow s
End Sub
End Module
ExternalFile info
End ExternalFile
End Project
The items on this page are in the following plugins: MBS Mac64bit Plugin.