Xojo Conferences

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCocoa/Drag Promise Receiver
Required plugins for this example: MBS MacBase Plugin, MBS MacCocoa Plugin, MBS MacOSX Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCocoa/Drag Promise Receiver
This example is the version from Thu, 20th Aug 2014.
Project "Drag Promise Receiver.rbp"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
End Class
Class Window1 Inherits Window
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
EventHandler Function DragEnter(obj As DragItem, action As Integer) As Boolean log CurrentMethodName Return false End EventHandler
EventHandler Sub DragExit(obj As DragItem, action As Integer) log CurrentMethodName End EventHandler
EventHandler Function DragOver(x As Integer, y As Integer, obj As DragItem, action As Integer) As Boolean log CurrentMethodName Return false End EventHandler
EventHandler Sub DropObject(obj As DragItem, action As Integer) log CurrentMethodName // check for promised file with plugin: dim n as NSDraggingInfoMBS = obj.NSDraggingInfoMBS if n <> nil then dim files() as FolderItem = n.promisedFilesDroppedAtDestination(SpecialFolder.Temporary) for each f as folderitem in files #if RBVersion < 2013 then log "got promised file: "+f.UnixpathMBS #else log "got promised file: "+f.NativePath #endif next else Break // older Real Studio? end if // normal xojo drop code: do if obj.FolderItemAvailable then #if RBVersion < 2013 then log "File arrived "+obj.FolderItem.UnixpathMBS #else log "File arrived "+obj.FolderItem.NativePath #endif end if if obj.TextAvailable then log "Text arrived: "+obj.Text end if if obj.RawDataAvailable("phfs") then log "phfs arrived." end if loop until not obj.NextItem End EventHandler
EventHandler Sub Open() log CurrentMethodName 'me.AcceptFileDrop FileTypes1.any 'me.AcceptRawDataDrop "phfs" // promised file 'me.AcceptTextDrop me.AcceptRawDataDrop "com.apple.pasteboard.promised-file-content-type" me.AcceptRawDataDrop "com.apple.pasteboard.promised-file-url" End EventHandler
Sub log(message as string) if LastMessage = message then // ignore else LastMessage = message List.AddRow message List.ScrollPosition = List.ListCount end if End Sub
Property LastMessage As string
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
Filetype special/any
End FileTypes1
End Project

Feedback, Comments & Corrections

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

MBS FileMaker Plugins