Using a simple Canvas as a button with the Backdrop as the state change indicator

Hi Folks,

I’m working on a modular control set based on set of Canvases within a Container. The state change is set in a combinataion of the MouseDown, MouseUp, and Paint events for each canvas. The parent canvas for each “button” instance is in a ControlSet named cvButton.

In the MouseDown event, I set a container level variable of 'tbIndex" equal to the index passed into the event. I then return False so that the MouseUp will fire calling Me.Invalidate.

In the paint event, I check the tIndex value and set that control’s backdrop to a different color/shade to indicate that it’s selected. I then set the other’s back to the original, unselected color.

When I run the code, the background of each canvas changes to the alternate color when clicked, but the remaining controls do not change back to the original, unselected color.

It’s impossible to debug this because the paint event fires continuously when the debugger focus shifts from the app to the IDE.

If I place the parent container onto a window and cause the top level window to refresh, the Canvasses update to the last selected button and the rest are reset to the unselected color.

Any thoughts on what I may have missed?

[code]MouseDown:
tIndex = index
Return False

MouseUp:
Me.Invalidate

Paint:
If index <> tIndex Then
g.FillRectGradient(0, 0, g.Width, g.Height, &c40404200, &c1D1D1D00)
Else
g.FillRectGradient(0, 0, g.Width, g.Height, &c57575B00, &c40404200)
End If
Self.UpdateNow
[/code]

MouseUp: self.Invalidate or self.refresh

and remove

self.updatenow

should do it.

if self affects the window and not the container, maybe

MouseUp: parent.Invalidate or parent.refresh

Parent was the magic sauce! Thanks, Jeff.