Example: /MacCocoa/Addressbook/Edit Distance values

Online Documentation   -   Statistics   -   FAQ   -   Plugin Parts (All, Dependencies)   -   Class hierarchy

New in Version 22.2 22.3 22.4 22.5 23.0 23.1 23.2 23.3 23.4 23.5 24.0 24.1

The list of the   topics,   classes,   interfaces,   controls,   modules,   global methods by category,   global methods by name,   screenshots,   licenses   and   examples.

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCocoa/Addressbook/Edit Distance values


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/Edit Distance values

This example is the version from Tue, 30th Jul 2012.

Project "Edit Distance values.xojo_binary_project"
FileTypes
Filetype special/any
End FileTypes
Class Window1 Inherits Window
Control List Inherits ListBox
ControlInstance List Inherits ListBox
EventHandler Sub CellLostFocus(row as Integer, column as Integer) dim p as ABPersonMBS dim s as string dim id as string dim r as ABRecordMBS // get id id=me.cell(row,0) if id<>"" then // find person for id r=a.recordForUniqueId(id) if r isa ABPersonMBS then p=ABPersonMBS(r) // get vcard if not p.setValue(me.cell(row,column),"Distance") then beep end if list.cell(row,column)=p.valueForProperty("Distance") msgBox "Set value to: "+p.valueForProperty("Distance") else System.DebugLog "person not found" end if else System.DebugLog "id not found" end if End EventHandler
EventHandler Sub Open() me.columntype(4)=3 End EventHandler
End Control
EventHandler Sub Activate() update End EventHandler
EventHandler Sub Close() a=nil quit End EventHandler
EventHandler Sub EnableMenuItems() if a<>Nil then filesave.enabled=a.HasUnsavedChanges end if End EventHandler
EventHandler Sub Open() dim p as ABPersonMBS a=new abAddressbookMBS p=new ABPersonMBS call p.addProperty "Distance",1 // type=1 is string End EventHandler
Function FileSave() As Boolean return a.save End Function
Sub update() list.deleteAllRows dim pa() as ABPersonMBS for each p as ABPersonMBS in pa dim uid as string = p.valueForProperty(a.kABUIDProperty) list.addrow uid dim l as integer = list.lastIndex list.cell(l,1)=p.valueForProperty(a.kABFirstNameProperty)+" "+p.valueForProperty(a.kABLastNameProperty) list.cell(l,4)=p.valueForProperty("Distance") dim m as ABMultiValueMBS = p.valueForProperty(a.kabAddressProperty) if m<>Nil then dim id as string = m.PrimaryIdentifier if id<>"" then dim dic as Dictionary = m.valueAtIndex(m.IndexForIdentifier(id)) if dic<>Nil then if dic.HasKey(a.kABAddressCityKey) then list.cell(l,2)=dic.Value(a.kABAddressCityKey) end if end if end if end if // gettting the primary email address is a little bit compilcate: m=p.valueForProperty(a.kABEmailProperty) if m<>Nil then dim id as string = m.PrimaryIdentifier if id<>"" then list.cell(l,3)=m.valueAtIndex(m.IndexForIdentifier(id)) end if end if next End Sub
Property Protected a As abaddressbookMBS
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileSave = "Save"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
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
End Project

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


💬 Ask a question or report a problem