A couple of thoughts here:
* The line command is very slow, considering you are only drawing horizonal or vertical lines you're better off with the rect command.
* Why not just pass the button one colour and it automatically creates the highlight and lowlight colours?
* Use the rectsoverlap command instead of a complete if mousex()>blah blah stuff
* Why have you got a flip within the function?
Personally I'd do something like this
Obviously you'd need to put checking so the hightlight/lowlight doesn't go beyond 0-255
* The line command is very slow, considering you are only drawing horizonal or vertical lines you're better off with the rect command.
* Why not just pass the button one colour and it automatically creates the highlight and lowlight colours?
* Use the rectsoverlap command instead of a complete if mousex()>blah blah stuff
* Why have you got a flip within the function?
Personally I'd do something like this
Graphics 800,600,32,2 Global UIR = 192 Global UIG = 192 Global UIB = 192 ; Example code ClsColor uir,uig,uib Repeat Cls For n=1 To 10 If Button(n*50,n*30,100,20,"Button "+n) Then Color 255,0,0:Text 0,0,"Button "+n+" clicked!!" Next Flip Until KeyHit(1) Function Button(x,y,Width,Height,Label$) Over = False If RectsOverlap (x,y,width,height,MouseX(),MouseY(),1,1) Then over = True If over Then Color uir+30,uig+30,uib+30 Else Color uir,uig,uib Rect x+1,y+1,width-2,height-2 Color uir+50,uig+50,uib+50 Rect x,y,width,1 Rect x,y,1,height Color uir-50,uig-50,uib-50 Rect x+width-1,y,1,height Rect x,y+height-1,width,1 Color 0,0,0 Text x+(width/2),y+(height/2),label,True,True If over And MouseDown(1) Then Return True Else Return False End Function
Obviously you'd need to put checking so the hightlight/lowlight doesn't go beyond 0-255