Nil value for color ?

I’m scratching my head on this one, I’m sure there is a simple answer:

I have set a property in my app of the type ‘Color’, but cant find a way to set it to a nil value.

I have tried ‘Nil’, ‘Null’, ‘0’, ‘-1’, double quotes, single quotes but none of these work.

Is there a way to set a color property to a nil value ?


Color is internally just an UInt32, so no nil possible.

Christians correct, but why do you want to set it nil? Maybe there’s a workaround for your case.

The value of the property can be set by the user, by picking a color of course.

I want to include an option where all of the colors selected by the user can be reset, so the user can essentially start over.

Well I may have found an option.

If I set my property option to &cFFFFFFFF, even if the user selects &cFFFFFF they compare differently.

Any thoughts if this is a good idea or not ?

RGB(0, 0, 0, 255)

Transparent BLACK would be a better choice that Transparent White

Yep, I did think black and / or white. I can use either.

This represents black with full transparency ?

whatever default you pick (white that is 100% transparent or black that is 100% transparent) its still not “this color has not been set by the user”

I’d just use a boolean flag along side the color to know but …

How does Xojo represent CLEAR for an iOS App (since that is a valid pre-defined color? [UIColor.clear]

So using a normal color value I should be safe with &c000000FF ?

Ok, so &cFF000000 then ?

actually you were correct… but I’d use something a user would NEVER (or be highly unlikely to select)


So I can set my default value to &c00000001 ?

The color choices open to the user come from a set of rectangles with RGB values already set.

If the user can only select opaque colors then any non-opaque color would work.

I’ve tried it with &c00000001 and all seems to work so far.

Thanks all for the input.

You could use an auto data type and notice the difference between the auto being color, false or nil.

e.g. like in this test:

[code] dim c as color = &cFF0000
dim a as auto = c
dim b as auto = nil

	if a = nil and b <> nil then
			Break // failed
			break // works
	end if[/code]

Xojo can represent it in the same ay Apple does since the declaration is just

open class var clear: NSColor { get } /* 0.0 white, 0.0 alpha */