Platforms to show: All Mac Windows Linux Cross-Platform

Required plugins for this example: MBS MacBase Plugin, MBS Main Plugin
You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCocoa/MovableByBackground
This example is the version from Sun, 17th Mar 2012.
Project "MovableByBackground.xojo_binary_project"
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
EventHandler Function MouseDown(X As Integer, Y As Integer) As Boolean windowFrame=self.NSWindowMBS.frame initialLocation = NSEventMBS.mouseLocation initialLocation.x = initialLocation.x - windowFrame.origin.x initialLocation.y = initialLocation.y - windowFrame.origin.y Return TRUE End EventHandler
EventHandler Sub MouseDrag(X As Integer, Y As Integer) currentLocation=NSEventMBS.mouseLocation newOrigin.x = (currentLocation.x-initialLocation.x) newOrigin.y = (currentLocation.y-initialLocation.y) self.NSWindowMBS.setFrameOrigin(newOrigin) End EventHandler
EventHandler Sub Open() if TargetCocoa then initialLocation = new NSPointMBS currentLocation= new NSPointMBS newOrigin = new NSPointMBS screenFrame = NSScreenMBS.mainScreen.frame windowFrame = self.NSWindowMBS.frame else MsgBox "Cocoa build only" quit end if End EventHandler
Property Private currentLocation As NSPointMBS
Property Private initialLocation As NSPointMBS
Property Private newOrigin As NSPointMBS
Property Private screenFrame As NSRectMBS
Property Private windowFrame As NSRectMBS
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
End Project

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

💬 Ask a question or report a problem
The biggest plugin in space...

Start Chat