Hi all
I am baffled, and I have been working through this for hours and I can’t find where I am going wrong.
I have a custom canvas class to be the basis for buttons with a mouseover effect. What I want is for the canvas to draw the image of the button, start with a transparent background and change color if the mouse hovers, and have a different highlight during the actual mouse press. The instances react to the mouse enter and mouse exit opposite of how I expect (the code below makes it work as expected, but doesn’t seem right to me). Also, when I go to a different page panel and then return, the buttons render with the mouse enter highlight active, until I actually move the mouse over them, and then they again react as expected to the mouse, but opposite of the way I think I have coded. The highlight on the mouse down event works fine. The image renders fine.
In the custom canvas class, I have:
Event Handlers:
MouseDown
mDown = True
Graphics.FillOval(0,0,32,32)
Graphics.ForeColor = app.colorAccent
Self.Invalidate(False)
Return True
MouseEnter
Hover = True
Self.Invalidate(False)
MouseExit
Hover = False
Self.Invalidate(False)
Open
Graphics.FillOval(0,0,32,32)
Graphics.ForeColor = app.colorTransparent)
Method - PaintButton
[code]//icon
Dim iconImage As Xojo.IO.FolderItem
iconImage = Xojo.IO.SpecialFolder.GetResource(actIcon)
Dim icon_ImagePath As New FolderItem(iconImage.Path, FolderItem.PathTypeNative)
Dim icon As Picture
Dim icon_scale As Double = 0.125
// icon highlight
select case hover
case false
Graphics.FillOval(0,0,32,32)
Graphics.ForeColor = app.colorLightBlue
case true
Graphics.FillOval(0,0,32,32)
Graphics.ForeColor = app.colorTransparent
end select
icon = Picture.Open(icon_ImagePath)
Graphics.DrawPicture(icon, 0, 0, icon.Width * icon_scale, icon.Height * icon_scale, 0, 0, icon.Width, icon.Height)[/code]
Properties - mDown, Hover (both boolean)
In the instances of the canvas, I have the following Event Handlers:
Mouse Up
mDown = False
If X > 0 And X < Self.Width _
And Y > 0 And Y < Self.Height Then
//do the action for this particular instance of the button
End If
and Paint
me.mPaintActButton("edit256.png") // tells the method in the custom class what image to use for this particular instance of the button
me.Invalidate
Any insight would be appreciated.