One way is to detect the mouse's position on the screen versus the object's position on the screen.
This can be done by making use of the
object screen x() and
object screen y() with
mousex() and
mousey().
A short code demonstrating this, but not test is:
if mousex()>=object screen x(1) and mousex()<object screen x(1)+40 or mousex()<=object screen x(1) and mousex()>object screen x(1)-40
if mousey()>=object screen y(1) and mousey()<object screen y(1)+40 or mousey()<=object screen y(1) and mousey()>object screen y(1)-40
if mouseclick()=1
end
endif
endif
endif