Colored pushbuttons, updated

I posted info on how to have colored pushbuttons a few months ago. I have found that when this pseudo pushbutton is pushed, it’s nice to have the button flash so the user knows it was pushed. Here is the updated code to do that.

Paint event

// the canvas for this puxhbutton is drawn in the IDE. I usually give it a height of 30
// and a width of 150. But you can make the canvas any size you want; which means your
// pushbutton is any size you want.

g.ForeColor = &cFFCC66 // color for the canvas
g.FillRoundRect (0,0,me.width,me.height,me.height,me.height) // give the canvas rounded corners and a color
g.ForeColor = &c000000 // switch to black
g.DrawRoundRect (0,0,me.width,me.height,me.height,me.height) // and give the canvas a black border
g.TextSize = 18 // caption size for your pseudo pushbutton
g.FontName = “Menlo” // caption font
g.Bold = FALSE // caption highlight
g.DrawString(“Print Table”,40,20) // draw the caption for this pseudo pushbutton. Modify the x,y position so your caption is centered in the pushbutton.

IF (DownClick) THEN // DownClick is set in the MouseDown event.
g.ForeColor = &c000000 // black
g.FillRoundRect (0,0,me.width,me.height,me.height,me.height) // button displays black
DownClick = FALSE

MouseDown event

DownClick = TRUE // this will turn the button black when
MyPushButton3.Refresh // the Paint event fires

RETURN TRUE // must return TRUE for the Mouseup event to work

MouseUp event

ContactsPrint // method to be executed with this pushbutton

PushButton3c.Refresh // fires the Paint event causing the button to return to its original color