Quantcast
Channel: Xojo Programming Forum - Latest topics
Viewing all articles
Browse latest Browse all 3673

Type mismatch error with colours

$
0
0

Sonoma 14.5, 2023r4.

I have some code in the Paint event of a DesktopCanvas. If I write it as follows:

if  (specialColourFlg=False)  then
  g.DrawingColor = Self.Window.BackgroundColor
else
  g.DrawingColor = localColour
end if

then it compiles without error. But I want to write it thus:

g.DrawingColor = if  (specialColourFlg=False, Self.Window.BackgroundColor, localColour)

If I do, then this line doesn’t compile; it gets a Type mismatch error, saying:

UsermsgContainer.umCanvas.Paint, line 33
Type mismatch error. Expected class ColorGroup, but got Color
g.DrawingColor = if (specialColourFlg=False, Self.Window.BackgroundColor, localColour)

Perhaps I’m just tired because it’s late, but I really can’t see what is wrong with my trinary if. Any suggestions?

I tried a simple example of this in an empty project with just a canvas and its Paint event, and of course that compiles.

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 3673

Trending Articles