Is there a way to change the Combobox background colour?
A declare for OSX would be fine.
Is there a way to change the Combobox background colour?
A declare for OSX would be fine.
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