Platforms to show: All Mac Windows Linux Cross-Platform

/MacCocoa/NSColorPanel Test


Required plugins for this example: MBS MacCF Plugin, MBS MacBase Plugin, MBS Main Plugin, MBS MacCocoa Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /MacCocoa/NSColorPanel Test

This example is the version from Tue, 21th Oct 2019.

Project "NSColorPanel Test.xojo_binary_project"
Class Window1 Inherits Window
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() dim x,y,w,h as double c.GetFrame x,y,w,h x=x+10 c.SetFrame x,y,w,h End EventHandler
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action() if c.Visible then MsgBox "IsVisible = True" else MsgBox "IsVisible = false" end if End EventHandler
End Control
Control PushButton3 Inherits PushButton
ControlInstance PushButton3 Inherits PushButton
EventHandler Sub Action() c.Show End EventHandler
End Control
Control PushButton4 Inherits PushButton
ControlInstance PushButton4 Inherits PushButton
EventHandler Sub Action() MsgBox c.Title End EventHandler
End Control
Control PushButton5 Inherits PushButton
ControlInstance PushButton5 Inherits PushButton
EventHandler Sub Action() c.Title="Hello World" End EventHandler
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control PushButton6 Inherits PushButton
ControlInstance PushButton6 Inherits PushButton
EventHandler Sub Action() const NSGrayModeColorPanel = 0 const NSRGBModeColorPanel = 1 const NSCMYKModeColorPanel = 2 const NSHSBModeColorPanel = 3 const NSCustomPaletteModeColorPanel = 4 const NSColorListModeColorPanel = 5 const NSWheelModeColorPanel = 6 const NSCrayonModeColorPanel = 7 c.SetPickerMode NSWheelModeColorPanel End EventHandler
End Control
Control PushButton7 Inherits PushButton
ControlInstance PushButton7 Inherits PushButton
EventHandler Sub Action() c.SetColor 0,0,0,1 // black End EventHandler
End Control
EventHandler Sub Close() c.Close Exception End EventHandler
EventHandler Sub Open() const NSGrayModeColorPanel = 0 const NSRGBModeColorPanel = 1 const NSCMYKModeColorPanel = 2 const NSHSBModeColorPanel = 3 const NSCustomPaletteModeColorPanel = 4 const NSColorListModeColorPanel = 5 const NSWheelModeColorPanel = 6 const NSCrayonModeColorPanel = 7 c=new MyNSColorPanelMBS c.ColorValue=BackColor c.setContinuous True #if Target32Bit then we=New MyWindowEvents we.ListenOnWindowsHandle c.WindowHandle #EndIf c.Show // show after setup so no black stuff is shown End EventHandler
Property c As NSColorPanelMBS
Property Protected we As mywindowEvents
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu7 = ""
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
MenuItem UntitledMenu6 = ""
MenuItem UntitledMenu5 = ""
MenuItem UntitledMenu4 = ""
End MenuBar
Class MyNSColorPanelMBS Inherits NSColorPanelMBS
EventHandler Sub Changed() Window1.BackColor=me.ColorValue Window1.Refresh Window1.UpdateNow End EventHandler
End Class
Class MyWindowEvents Inherits CarbonWindowsEventsMBS
EventHandler Sub WindowBoundsChanging(original as object, previous as object, current as object, flags as integer) system.debuglog "WindowBoundsChanging" End EventHandler
EventHandler Function WindowClose() As boolean MsgBox "Close" End EventHandler
EventHandler Function WindowCloseAll() As boolean system.debuglog "CloseAll" End EventHandler
EventHandler Function WindowCollapse() As boolean system.debuglog "Collapse" End EventHandler
EventHandler Function WindowCollapseAll() As boolean system.debuglog "CollapseAll" End EventHandler
EventHandler Function WindowCollapsed() As boolean system.debuglog "Collapsed" End EventHandler
EventHandler Function WindowCollapsing() As boolean system.debuglog "Collapsing" End EventHandler
EventHandler Function WindowExpand() As boolean system.debuglog "Expand" End EventHandler
EventHandler Function WindowExpandAll() As boolean system.debuglog "ExpandAll" End EventHandler
EventHandler Function WindowExpanded() As boolean system.debuglog "Expanded" End EventHandler
EventHandler Function WindowExpanding() As boolean system.debuglog "Expanding" End EventHandler
EventHandler Function WindowHidden() As boolean system.debuglog "Hidden" End EventHandler
EventHandler Function WindowHiding() As boolean system.debuglog "Hiding" End EventHandler
EventHandler Function WindowShowing() As boolean system.debuglog "Showing" End EventHandler
EventHandler Function WindowShown() As boolean system.debuglog "Shown" End EventHandler
EventHandler Function WindowZoom() As boolean system.debuglog "Zoom" End EventHandler
EventHandler Function WindowZoomAll() As boolean system.debuglog "ZoomAll" End EventHandler
EventHandler Function WindowZoomed() As boolean system.debuglog "Zoomed" End EventHandler
End Class
Class App Inherits Application
EventHandler Sub Open() if TargetMachO=false then MsgBox "This example needs a MachO target running on Mac OS X." quit end if End EventHandler
End Class
End Project

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


The biggest plugin in space...