Platforms to show: All Mac Windows Linux Cross-Platform

/Mac64bit/Contacts/CNContactViewController 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/CNContactViewController test

This example is the version from Tue, 6th Feb 2023.

Project "CNContactViewController test.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() Self.viewController = New CNContactViewControllerMBS // query view to load it dim v as NSViewMBS = viewController.view // load contact viewController.Contact = TestContact // show WindowViewController.presentViewControllerAsModalWindow viewController // close after 5 seconds CloseTimer.Mode = timer.ModeSingle End EventHandler
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action() Self.viewController = New CNContactViewControllerMBS // query view to load it dim v as NSViewMBS = viewController.view // load contact viewController.Contact = TestContact // show WindowViewController.presentViewControllerAsSheet viewController // close after 5 seconds CloseTimer.Mode = timer.ModeSingle End EventHandler
End Control
Control PushButton3 Inherits PushButton
ControlInstance PushButton3 Inherits PushButton
EventHandler Sub Action() Self.viewController = New CNContactViewControllerMBS // query view to load it dim v as NSViewMBS = viewController.view // load contact viewController.Contact = TestContact // show WindowViewController.presentViewControllerAsPopover viewController, nil, _ me.NSButtonMBS, WindowViewController.NSMaxXEdge, WindowViewController.PopoverBehaviorTransient // close after 5 seconds CloseTimer.Mode = timer.ModeSingle End EventHandler
End Control
Control CloseTimer Inherits Timer
ControlInstance CloseTimer Inherits Timer
EventHandler Sub Action() if viewController <> nil then WindowViewController.dismissViewController viewController viewController = nil end if End EventHandler
End Control
Control PushButton4 Inherits PushButton
ControlInstance PushButton4 Inherits PushButton
EventHandler Sub Action() Self.viewController = New CNContactViewControllerMBS // query view to load it dim v as NSViewMBS = viewController.view // load contact viewController.Contact = TestContact // show dim n as NSViewMBS = canvas1.NSViewMBS v.frame = new NSRectMBS(0, 0, n.frame.Width, n.frame.Height) n.addSubview v End EventHandler
End Control
Control Canvas1 Inherits Canvas
ControlInstance Canvas1 Inherits Canvas
EventHandler Sub Paint(g As Graphics, areas() As REALbasic.Rect) 'g.ForeColor = &cFF000033 'g.FillRect 0, 0, g.Width, g.Height End EventHandler
End Control
EventHandler Sub Open() dim win as NSWindowMBS = self.NSWindowMBS WindowViewController = NSViewControllerMBS.contentViewController(win) if WindowViewController = nil then // if window has no view controller, we make a temporary one WindowViewController = new NSViewControllerMBS WindowViewController.View = win.contentView end if TestContact = New CNMutableContactMBS//contacts(0) TestContact.givenName="Max" TestContact.familyName="Tyrtania" TestContact.organizationName="World Inc." TestContact.departmentName="Science lab" TestContact.jobTitle="Master brain" // To fetch the note property in iOS 13 or later or macOS 16 or later, add the com.apple.developer.contacts.notes entitlement to your app. The entitlement requires permission from Apple to use, and you can’t publicly distribute your app until you have permission to use it. For more information about adding the entitlement and getting permission, see com.apple.developer.contacts.notes. 'TestContact.note="1"+EndOfLine+"2"+EndOfLine+"3"+EndOfLine Dim phoneNumber As New CNPhoneNumberMBS("015229270736") Dim lv As New CNLabeledValueMBS(CNLabeledValueMBS.CNLabelHome,phoneNumber) Dim lvs() As CNLabeledValueMBS lvs.Append(lv) TestContact.setphoneNumbers(lvs) End EventHandler
Property TestContact As CNMutableContactMBS
Property WindowViewController As NSViewControllerMBS
Property viewController As CNContactViewControllerMBS
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
ExternalFile info
End ExternalFile
End Project

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


The biggest plugin in space...