API2 BackgroundColor

Investigating moving my apps to API 2

One I can’t seem to fathom out is:
Code in paint event:
“if BackgroundColor.value < switchBWvalue then”

gives error:
Type “ColorGroup” has no member named “value”

Yesd, it have VALUES with an ending ‘s’ :japanese_ogre:

BackgroundColor.Value makes no sense since BackgroundColor IS a variable. Your statement should be

if BackgroundColor < switchBWvalue then`

assuming that switchBWvalue is a color Value.

Try this one:

if BackgroundColor.value < switchBW.value then

But BackgroundColor is a color data type and BackgroundColor.value is a double data type from the HSV representation. I just want to know how “dark” the color is.
It has always worked (before API 2).

But BackgroundColor is no longer just a Color data type. It’s a ColorGroup. Now, ColorGroups have a pair of operator_convert on them which will automatically convert to and from Color for assignments, but you’ll have to convert to be able to use the methods. So you’ll either need to do this:

Var c as Color = BackgroundColor
If c.value < switchBWValue.value Then


If Ctype(BackgroundColor, Color).Value < switchBWValue.value Then

Thanks Greg. I am trying to keep up.
switchBWvalue is a double, so I assume
Var c as Color = BackgroundColor
If c.value < switchBWValue Then
will work.

It should

I have to ask:

Where in the Xojo docs could I have found a solution to this myself?

I am concerned now that I should not even attempt to convert to API2.
My “small” app produced about 500 errors, only some of which can be fixed “mechanically”.


As with other changes the docs weren’t updated. Please write to Xojo to get https://documentation.xojo.com/BackgroundColor updated.

As for API2 you have to do it the same way as always: you just need to hit your head often enough on the desk. Everything will be better afterwards.

Errors, or warnings?

Errors - but the number is now 374 after fixing a few “obvious” ones by global find and replace.

Just out of curiosity… is there some compelling reason that you are converting? You could easily leave your project in API 1 and then just start using API 2 for new projects.

In fact I just keep everything in API 1; and for new projects I recycle existing projects as someone else said a couple of days ago.
Of course, I do only desktop!

Just me. Though I am a hobbyist, I take pride in my programs. After a career in IT (remember “transaction processing” and “super-minis” and “3rd generation software”?), I fell in love with RealBasic over 20 years ago and through thick and thin have maintained and enhanced my first ever program (midi play and animate) through all the MacOS and Xojo changes since then. Some involved major re-design under the hood. Keeping up with the latest MacOS and latest Xojo I saw as a challenge and achievement. For some reason, I view moving to API2 as a chore (sorry Beatrix), but neither can I continue to develop with something that in the back of my mind is not the latest (and presumably from Xojo’s standpoint - the “best”). I did not fall out of love with Xojo, Xojo fell out of love with me. Who knows, I might go back to Scratch with my grandchildren or do something I have been putting off for years - look at Xcode and C++. I have already cancelled my auto-renew and I am looking at giving away my Xojo stuff to anyone who is interested.