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: /MacBase/NSColorSampler
This example is the version from Sun, 10th Aug 2019.
Project "NSColorSampler.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open()
If NSColorSamplerMBS.Available Then
// okay
Else
MsgBox "Needs MacOS 10.15 or newer"
Quit
End If
End EventHandler
End Class
Class MainWindow Inherits Window
Control ShowButton Inherits PushButton
ControlInstance ShowButton Inherits PushButton
EventHandler Sub Action()
n.show
End EventHandler
End Control
Control Canvas1 Inherits Canvas
ControlInstance Canvas1 Inherits Canvas
End Control
Control Label1 Inherits Label
ControlInstance Label1 Inherits Label
End Control
EventHandler Sub Open()
n = New NSColorSampler
n.output = canvas1
End EventHandler
Property n As NSColorSampler
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
Class NSColorSampler Inherits NSColorSamplerMBS
EventHandler Sub Completed(selectedColor as NSColorMBS)
If selectedColor = Nil Then
output.Backdrop = Nil
Else
Dim p As New Picture(output.Width, output.Height)
p.Graphics.ForeColor = selectedColor.colorValue
p.Graphics.FillRect 0, 0, p.Width, p.Height
output.Backdrop = p
End If
End EventHandler
Property output As canvas
End Class
End Project
The items on this page are in the following plugins: MBS MacBase Plugin.