Platforms to show: All Mac Windows Linux Cross-Platform
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacExtras/Retina Drag Image
This example is the version from Mon, 22th Nov 2015.
Project "Retina Drag Image.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open()
InstallDragImageMBS
End EventHandler
End Class
Class Window1 Inherits Window
Control Canvas1 Inherits MyCanvas
ControlInstance Canvas1 Inherits MyCanvas
End Control
Control CheckBox1 Inherits CheckBox
ControlInstance CheckBox1 Inherits CheckBox
EventHandler Sub Action()
canvas1.HighRes = me.Value
End EventHandler
End Control
EventHandler Sub Open()
// 500 pixel wide, so with retina we get 250px
canvas1.pic = LogoMBS(500)
End EventHandler
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
SetRetina
End SetRetina
Class MyCanvas Inherits Canvas
EventHandler Function MouseDown(X As Integer, Y As Integer) As Boolean
// scale down, so Xojo calculates right position
dim p as new Picture(me.Width, me.Height)
p.Graphics.DrawPicture pic, 0, 0, p.Width, p.Height, 0, 0, pic.Width, pic.Height
// new drag item relative to control
dim d as new DragItem(self, 0, 0, me.Width, me.Height, p)
// actually drag full size image
d.Picture = me.pic
if HighRes then
// and make nsimage with control size and full image content
dim ni as new NSImageMBS(me.pic)
ni.setSize me.Width, me.Height
// tell plugin to replace Xojo's picture for drag with ours
SetNextDragImageMBS ni
end if
// and run the drag
d.Drag
Return true
End EventHandler
EventHandler Sub Paint(g As Graphics, areas() As REALbasic.Rect)
// draw at size of control, about 50% size
g.DrawPicture pic, 0, 0, g.Width, g.Height, 0, 0, pic.Width, pic.Height
End EventHandler
Property HighRes As Boolean
Property Pic As Picture
End Class
End Project
The items on this page are in the following plugins: MBS MacExtras Plugin.