Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/MacFrameworks/Sharing/Custom Sharing Service
Function:
Required plugins for this example: MBS MacBase Plugin, MBS MacFrameworks Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacFrameworks/Sharing/Custom Sharing Service
This example is the version from Tue, 30th Jul 2012.
Project "Custom Sharing Service.rbp"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open() dim logo as picture = LogoMBS(500) dim image as new NSImageMBS(logo) mydelegate = new MyNSSharingServiceDelegateMBS customService = new PrintService("Print images", image, image, mydelegate) End EventHandler
End Class
Class Window1 Inherits Window
Control BevelButton1 Inherits BevelButton
ControlInstance BevelButton1 Inherits BevelButton
EventHandler Sub Action() picker = new myNSSharingServicePickerMBS(images) dim v as NSViewMBS = me.NSViewMBS dim r as NSRectMBS = new NSRectMBS(0,0,0,0) // default // somehow Real Studio messes up the coordinate system r = new NSRectMBS(r.Origin.x, r.Origin.y + 125, r.Size.Width, r.Size.Height) picker.showRelativeToRect(r, v, picker.NSMaxYEdge) End EventHandler
End Control
EventHandler Sub Open() if not NSSharingServicePickerMBS.Available then MsgBox "Mac OS X 10.8 required" quit end if logo = LogoMBS(500) image = new NSImageMBS(logo) images = new NSSharingServiceItemsMBS images.AddImage image End EventHandler
Property image As NSImageMBS
Property images As NSSharingServiceItemsMBS
Property logo As Picture
Property picker As NSSharingServicePickerMBS
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class MyNSSharingServiceDelegateMBS Inherits NSSharingServiceDelegateMBS
EventHandler Sub didFailToShareItems(service as NSSharingServiceMBS, items as NSSharingServiceItemsMBS, error as NSErrorMBS) System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub didShareItems(service as NSSharingServiceMBS, items as NSSharingServiceItemsMBS) System.DebugLog CurrentMethodName End EventHandler
EventHandler Sub willShareItems(service as NSSharingServiceMBS, items as NSSharingServiceItemsMBS) System.DebugLog CurrentMethodName End EventHandler
End Class
Class PrintService Inherits CustomNSSharingServiceMBS
EventHandler Sub performCustomService() MsgBox CurrentMethodName End EventHandler
End Class
Class MyNSSharingServicePickerMBS Inherits NSSharingServicePickerMBS
EventHandler Function delegateForSharingService(service as NSSharingServiceMBS) As NSSharingServiceDelegateMBS Return globals.mydelegate End EventHandler
EventHandler Sub didChooseSharingService(service as NSSharingServiceMBS) if service <>nil then MsgBox CurrentMethodName+": "+service.title else MsgBox CurrentMethodName+": nil" end if End EventHandler
EventHandler Function sharingServicesForItems(items as NSSharingServiceItemsMBS, proposedServices() as NSSharingServiceMBS) As NSSharingServiceMBS() // add us if we can handle it if customService.canPerformWithItems(items) then proposedServices.Append customService end if Return proposedServices End EventHandler
End Class
Module Globals
Property customService As PrintService
Property mydelegate As MyNSSharingServiceDelegateMBS
End Module
End Project

Feedback, Comments & Corrections

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





Links
MBS Xojo Plugins