FutureBasic Logo

<<    Index    >> FutureBasic

ColorPanel   object



Description
A standard user interface for selecting color in an app.
 

Example

#define DEFAULT_COLOR fn ColorWithDeviceRGB( 0.0, 0.5, 0.0, 1.0 )

_window = 1
begin enum 1
_label
_btn
end enum

void local fn BuildWindow
window _window, @"ColorPanel Example", (0,0,330,250)

textlabel _label, @"FutureBasic", (18,144,294,59)
ControlSetFont( _label, fn FontBoldSystemFontOfSize( 50 ) )
ControlSetAlignment( _label, NSTextAlignmentCenter )
TextFieldSetTextColor( _label, DEFAULT_COLOR )

button _btn,,, @"", (133,45,64,64),, NSBezelStyleSmallSquare
ButtonSetBordered( _btn, NO )
ButtonSetImage( _btn, NSImageNameColorPanel )
ButtonSetImageScaling( _btn, NSImageScaleProportionallyUpOrDown )

ColorPanelSetColor( DEFAULT_COLOR ) // set the colorpanel color or we'll crash
end fn

void local fn DoDialog( ev as long )
select ( ev )
case _btnClick : ColorPanelShow
case _colorPanelChangeColor : TextFieldSetTextColor( _label, fn ColorPanelColor )
end select
end fn

fn BuildWindow

on dialog fn DoDialog

HandleEvents
Dialog Event
_colorPanelChangeColor
 
Apple documentation
NSColorPanel