SDL newb: How to make an Onject "klickable"?

hi,

i?m new to sdl/c++. how can i make an objekt “klickable” ? like with
glLoadName ? i?m drawing some circles with the SDL_gfxPrimitives library

  • some text with SDL_ttf. Now i want the user to klick on the text/the
    circle/or parts of the circle. keyboard input already works.

    thx,jurri

you can either use a seperate gui set (paragui, …)
or do everything yourself.

for example: buttons are quite easy to implement:
save the rectangle of your button and if a mousebutton is pressed, check if
the mouse x,y is inside the button.

maybe this helps:

if_mouse_button_left_is_pressed
if(mousex >= button->rect.x && mousex <= button->rect.x + button->rect.w
&& mousey >= button->rect.y && mousey <= button->rect.y + button->rect.h){

object_is_klicked
}

circles are just the same, but the x,y check is different.

something like:
if(mousex >= center.x - radius && mousex <= center.x +radius
&& mousey >= center.y - radius && mousey <= center.y + radius)

got it?> ----- Original Message -----

From: zentrum_des_wissens@freenet.de (jurri)
To:
Sent: Sunday, July 06, 2003 5:19 PM
Subject: [SDL] SDL newb: How to make an Onject “klickable” ?

hi,

i?m new to sdl/c++. how can i make an objekt “klickable” ? like with
glLoadName ? i?m drawing some circles with the SDL_gfxPrimitives library

  • some text with SDL_ttf. Now i want the user to klick on the text/the
    circle/or parts of the circle. keyboard input already works.

    thx,jurri


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl