Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/MacFrameworks/Sharing/Sharing Services
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/Sharing Services
This example is the version from Mon, 11th Dec 2016.
Project "Sharing Services.rbp"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control BevelButton1 Inherits BevelButton
ControlInstance BevelButton1 Inherits BevelButton
EventHandler Sub Action() share me, images End EventHandler
End Control
Control Listbox1 Inherits Listbox
ControlInstance Listbox1 Inherits Listbox
End Control
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
Control Listbox2 Inherits Listbox
ControlInstance Listbox2 Inherits Listbox
End Control
Control Label2 Inherits Label
ControlInstance Label2 Inherits Label
End Control
Control Listbox3 Inherits Listbox
ControlInstance Listbox3 Inherits Listbox
End Control
Control Label3 Inherits Label
ControlInstance Label3 Inherits Label
End Control
Control Listbox4 Inherits Listbox
ControlInstance Listbox4 Inherits Listbox
End Control
Control Label4 Inherits Label
ControlInstance Label4 Inherits Label
End Control
Control BevelButton2 Inherits BevelButton
ControlInstance BevelButton2 Inherits BevelButton
EventHandler Sub Action() share me, urls End EventHandler
End Control
Control BevelButton3 Inherits BevelButton
ControlInstance BevelButton3 Inherits BevelButton
EventHandler Sub Action() share me, texts End EventHandler
End Control
Control BevelButton4 Inherits BevelButton
ControlInstance BevelButton4 Inherits BevelButton
EventHandler Sub Action() share me, files End EventHandler
End Control
EventHandler Sub Open() dim p as Picture = LogoMBS(500) dim n as new NSImageMBS(p) image = n if not NSSharingServicePickerMBS.Available then MsgBox "Mac OS X 10.8 required" quit end if // build a few item collections images = new NSSharingServiceItemsMBS images.AddImage image urls = new NSSharingServiceItemsMBS urls.AddURL "http://www.mbsplugins.de/" texts = new NSSharingServiceItemsMBS texts.AddText "Hello World. This is a great app!" files = new NSSharingServiceItemsMBS files.AddFile GetFolderItem("/Library/Desktop Pictures/Beach.jpg", FolderItem.PathTypeShell) // and list services Check Listbox1, images Check Listbox2, urls Check Listbox3, texts Check Listbox4, files End EventHandler
Sub Check(l as listbox, items as NSSharingServiceItemsMBS) dim services() as NSSharingServiceMBS = NSSharingServiceMBS.sharingServicesForItems(items) for each service as NSSharingServiceMBS in Services l.AddRow service.title dim image as NSImageMBS = service.image if image<>Nil then image.setSize 16, 16 dim pic as Picture = image.CopyPictureWithMask l.RowPicture(l.LastIndex) = pic end if next End Sub
Sub Share(b as BevelButton, items as NSSharingServiceItemsMBS) picker = new NSSharingServicePickerMBS(items) dim v as NSViewMBS = b.NSViewMBS dim r as NSRectMBS = v.bounds // somehow Real Studio messes up the coordinate system r = new NSRectMBS(r.Origin.x, r.Origin.y + 85, r.Size.Width, r.Size.Height) picker.showRelativeToRect(r, v, picker.NSMaxYEdge) End Sub
Note "Note"
Apple does no longer really support Sharing in 32-bit apps with newer macOS versions. Please use 64-bit apps to share.
Property files As NSSharingServiceItemsMBS
Property image As NSImageMBS
Property images As NSSharingServiceItemsMBS
Property picker As NSSharingServicePickerMBS
Property texts As NSSharingServiceItemsMBS
Property urls As NSSharingServiceItemsMBS
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
End Project

Feedback, Comments & Corrections

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




Links
MBS Xojo PDF Plugins