Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCocoa/Addressbook/Change my name
Function:
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/Change my name
This example is the version from Tue, 30th Jul 2012.
Project "Change my name.rbp"
FileTypes
Filetype text
End FileTypes
Class Window1 Inherits Window
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control newname Inherits TextField
ControlInstance newname Inherits TextField
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() Change Update End EventHandler
End Control
Control StaticText2 Inherits Label
ControlInstance StaticText2 Inherits Label
End Control
Control currentname Inherits Label
ControlInstance currentname Inherits Label
End Control
EventHandler Sub Open() a=new abAddressbookMBS Update Newname.text=Currentname.text End EventHandler
Protected Sub Change() dim s as string dim p as ABPersonMBS p=a.Owner if not p.setValue(newname.text,a.kABFirstNameProperty) then MsgBox "Failed to set the new name." Return end if if not a.Save then MsgBox "Failed to save the new name!" Return end if Exception MsgBox "Exception in the Change method!" End Sub
Protected Sub Update() dim s as string dim p as ABPersonMBS p=a.owner s=p.valueForProperty(a.kABFirstNameProperty) currentname.text=s Exception MsgBox "Exception in the Update method!" End Sub
Property Protected a 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
End Project

Feedback, Comments & Corrections

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




Links
MBS Xojo Plugins