Xojo Conferences
XDCMay2019MiamiUSA

Platforms to show: All Mac Windows Linux Cross-Platform

/MacCocoa/NSColorPanel Test
Function:
Required plugins for this example: MBS MacBase Plugin, MBS MacCF Plugin, MBS MacClassic Plugin, MBS MacCocoa Plugin, MBS Main 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 Sun, 17th Mar 2012.
Project "NSColorPanel Test.rbp"
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 dim b as Boolean c=new MyNSColorPanelMBS c.ColorValue=BackColor c.setContinuous True we=new MyWindowEvents we.ListenOnWindowsHandle c.WindowHandle t=new MyDragTracker b=t.AttachWindow(self) r=new MyDragReceiver b=r.AttachWindow(self) c.Show // show after setup so no black stuff is shown End EventHandler
Property c As NSColorPanelMBS
Property Protected r As MyDragReceiver
Property Protected t As mydragTracker
Property Protected we As mywindowEvents
End Class
MenuBar Menu
MenuItem UntitledMenu3 = ""
MenuItem UntitledMenu2 = "File"
MenuItem FileQuit = "Quit"
MenuItem UntitledMenu0 = "Edit"
MenuItem EditUndo = "Undo"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "Cut"
MenuItem EditCopy = "Copy"
MenuItem EditPaste = "Paste"
MenuItem EditClear = "Clear"
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
Class MyDragTracker Inherits DragTrackerMBS
EventHandler Function Dragging(message as integer, drag as DragItemMBS) As boolean dim r,g,b,a as Single if Window1.c.GetColorFromDrag(r,g,b,a) then Return true // is color... end if End EventHandler
End Class
Class MyDragReceiver Inherits DragReceiverMBS
EventHandler Function Received(drag as DragItemMBS) As boolean dim r,g,b,a as Single if Window1.c.GetColorFromDrag(r,g,b,a) then window1.StaticText1.TextColor=rgb(r*255,g*255,b*255) Return true else beep Return false end if End EventHandler
End Class
End Project

Feedback, Comments & Corrections

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




Links
MBS FileMaker tutorial videos