I'd take a look at the rectsoverlap function
ie
If rectsoverlap(x,y,width,height,mousex(),mousey(),1,1) and mousedown(1) then 'set colour'
Also I'd load this into a function so you get something like:
ie
If rectsoverlap(x,y,width,height,mousex(),mousey(),1,1) and mousedown(1) then 'set colour'
Also I'd load this into a function so you get something like:
; Set up Colours Dim Colours(8,2) Data 255,0,0 Data 0,255,0 Data 0,0,255 Data 255,255,255 Data 255,255,0 Data 255,0,255 Data 0,255,255 For n=2 To 8 Read Colours(n,0),Colours(n,1),Colours(n,2) Next ; Set the default colour SelectedColor = 2 Repeat ; Draw the buttons and change colour if the mouse is clicked For n=2 To 8 If colourbutton(n*20,0,Colours(n,0),Colours(n,1),Colours(n,2)) Then SelectedColor = n Next ; Draw a block of the selected colour Color Colours(SelectedColor,0),Colours(SelectedColor,1),Colours(SelectedColor,2) Rect 0,20,400,40 Until KeyHit(1) Function ColourButton(x,y,r,g,b) Over = False ; Check if the mouse is over a button and set the over flag If RectsOverlap(x,y,16,16,MouseX(),MouseY(),1,1) Then Over = True ; If the mouse is over a button set the border colour to white, otherwise make it grey If Over Then Color 255,255,255 Else Color 100,100,100 ; Draw the border Rect x,y,16,16,False ; set the colour to the passed colour and draw the rect in the middle of the border Color r,g,b Rect x+1,y+1,14,14,True ; if you're pressing the mouse and you're over the button return true else return false If MouseDown(1) And over Then Return True Else Return False End Function