[SDL] How to use buttons

Bill Kendrick nbs at sonic.net
Thu Apr 5 08:49:46 PDT 2007


On Thu, Apr 05, 2007 at 11:16:33AM +0700, Patricia Curtis wrote:
> my personal choice is to do the action on the mouse up
> rather than the down.

And, of course, most common UIs only respond to mouse-up if you're
still within the widget you mouse-downed in.


> its a simple collision check
> if(MouseX>ButtonRect.x && MouseX<ButtonRect.x+ButtonRect.w && MouseY>
> ButtonRect.y && MouseY<ButtonRect.y+ButtonRect.h)
> {
> //Do somthing
> }

MouseX >= ButtonRect.x ... MouseY >= ButtonRect.y ... would be better. ;)

-bill!


More information about the SDL mailing list