ComboBox background colour

Is there a way to change the Combobox background colour?

A declare for OSX would be fine. :wink:

Sub Open()
dim n as NSComboBoxMBS = me.NSComboBoxMBS

n.drawsBackground = true
n.backgroundColor = NSColorMBS.redColor

End Sub

in the open event of Combobox control.

This will make it red… if you need a different color, look at the reference for NSColor.

[code] declare function cell lib “Cocoa” selector “cell” (obj as ptr) as ptr
declare sub setBackgroundColor lib “Cocoa” selector “setBackgroundColor:” (obj as ptr, color as ptr)
soft declare function NSClassFromString lib “Cocoa” (classname as CFStringRef) as ptr
soft declare function redColor lib “Cocoa” selector “redColor” (obj as ptr) as ptr

dim red as ptr=redColor(NSClassFromString(“NSColor”))
setBackgroundColor(cell(ptr(me.Handle)), red)[/code]

or

me.nsComboBoxMBS.drawsBackground=true
me.nsComboBoxMBS.backgroundColor=NSColorMBS.grayColor
me.nsComboBoxMBS.textColor= NSColorMBS.whiteColor
me.nsComboBoxMBS.Bordered=true

Is there also a way to remove the up and down arrows at the right?

With the NSPopupmenu this is possible by using the setArrowPosition, but the ComboBox does not have this property (so it seems).

More legibly (than my first post) via declares, for the interested…

[code]declare function NSClassFromString lib “Cocoa” (classname as CFStringRef) as ptr
declare function whiteColor lib “Cocoa” selector “whiteColor” (obj as ptr) as ptr
declare function grayColor lib “Cocoa” selector “grayColor” (obj as ptr) as ptr
declare sub setBackgroundColor lib “Cocoa” selector “setBackgroundColor:” (obj as ptr, color as ptr)
declare sub setTextColor lib “Cocoa” selector “setTextColor:” (obj as ptr, color as ptr)
declare sub setDrawsBackground lib “Cocoa” selector “setDrawsBackground:” (obj as ptr, value as Boolean)
declare sub setButtonBordered lib “Cocoa” selector “setButtonBordered:” (obj as ptr, value as Boolean)

dim white as ptr=whiteColor(NSClassFromString(“NSColor”))
dim gray As ptr=grayColor(NSClassFromString(“NSColor”))
dim mcell as ptr=ptr(me.Handle)

setDrawsBackground(mcell,true)
setBackgroundColor(mcell, gray)
setTextColor(mcell,white)
setButtonBordered(mcell,true)[/code]

To remove the arrow, I think you’d have to dig into the control and subviews… not sure how a combobox fits together beyond the control/cell level…

[quote=90833:@Christian Schmitz]Sub Open()
dim n as NSComboBoxMBS = me.NSComboBoxMBS

n.drawsBackground = true
n.backgroundColor = NSColorMBS.redColor

End Sub

in the open event of Combobox control.[/quote]

If I have a color in Xojo, like &cE6E6E6, how would I make it a NSColorMBS? How do I make a Xojo Color into a NSCColorMBS?

Am I understandable? I do have user defined color values for setting the background color of textfields etc. I would like to have the same color as a background of comboboxes (OSX). I need a way to take that user defined color value and make it a NSColorMBS.

Assuming
dim thecolor as color=&cE6E6E6

Here’s the declare way…

[code] declare function NSClassFromString lib “Cocoa” (classname as CFStringRef) as ptr
declare function colorWithSRGBRedgreenbluealpha lib “Cocoa” selector “colorWithSRGBRed:green:blue:alpha:”_
(obj as ptr, red as single,green as single,blue as single,alpha as single) as ptr

dim otherColor as ptr=colorWithSRGBRedgreenbluealpha(NSClassFromString(“NSColor”),thecolor.red/255,thecolor.green/255,thecolor.blue/255,1)
[/code]

MBS:

dim c As NSColorMBS=NSColorMBS.colorWithDeviceRGB(thecolor.red/255,thecolor.green/255,thecolor.blue/255)

Great! It worked! Thanks, Jim!

[quote=90833:@Christian Schmitz]Sub Open()
dim n as NSComboBoxMBS = me.NSComboBoxMBS

n.drawsBackground = true
n.backgroundColor = NSColorMBS.redColor

or this code

me.nsComboBoxMBS.drawsBackground=true
me.nsComboBoxMBS.backgroundColor=NSColorMBS.grayColor
me.nsComboBoxMBS.textColor= NSColorMBS.whiteColor
me.nsComboBoxMBS.Bordered=true

[/quote]

when i used the above code with the latest beta mbs plugin i got runtime error when i clicking on continue.

Location: Common/plugin.cpp:5484
Condition: pluginEntryTable.GetEntry( entrypointName, out )
Message: can’t find plugin method NSDraggingInfoMBS.draggingSource as variant

Location: Common/plugin.cpp:5484
Condition: pluginEntryTable.GetEntry( entrypointName, out )
Message: can’t find plugin method NSDraggingInfoMBS.draggingDestinationWindow as NSWindowMBSê6Júp

Location: Common/plugin.cpp:5484
Condition: pluginEntryTable.GetEntry( entrypointName, out )
Message: can’t find plugin method NSDraggingInfoMBS.draggingLocation as NSPointMBS

Location: Common/plugin.cpp:5484
Condition: pluginEntryTable.GetEntry( entrypointName, out )
Message: can’t find plugin method NSDraggingInfoMBS.draggedImage as NSImageMBStMBS

Location: Common/plugin.cpp:5484
Condition: pluginEntryTable.GetEntry( entrypointName, out )
Message: can’t find plugin method NSDraggingInfoMBS.draggingPasteboard as NSPasteboardMBS?ë8†?

Location: Common/plugin.cpp:5484
Condition: pluginEntryTable.GetEntry( entrypointName, out )
Message: can’t find plugin method NSDraggingInfoMBS.draggedImageLocation as NSPointMBS

[quote=90885:@jim mckay]Assuming
dim thecolor as color=&cE6E6E6

[code] declare function NSClassFromString lib “Cocoa” (classname as CFStringRef) as ptr
declare function colorWithSRGBRedgreenbluealpha lib “Cocoa” selector “colorWithSRGBRed:green:blue:alpha:”_
(obj as ptr, red as single,green as single,blue as single,alpha as single) as ptr

dim otherColor as ptr=colorWithSRGBRedgreenbluealpha(NSClassFromString(“NSColor”),thecolor.red/255,thecolor.green/255,thecolor.blue/255,1)
[/code]

MBS:

dim c As NSColorMBS=NSColorMBS.colorWithDeviceRGB(thecolor.red/255,thecolor.green/255,thecolor.blue/255) [/quote]

i try all the other code not using MBS and it work except the above code… for other colour.

sorry forget the above… i forgot to include the leopard mbs plugin.

the nsComboBoxMBS work now… yuppie