Added a cleaner way to set the default cursor.

Added a way to cycle through the default cursor in testcursor.c
This commit is contained in:
Sam Lantinga 2011-02-27 21:36:23 -08:00
parent 99de5726b1
commit 9959455aee
4 changed files with 30 additions and 13 deletions

View file

@ -147,7 +147,7 @@ main(int argc, char *argv[])
{
SDL_Surface *screen;
SDL_bool quit = SDL_FALSE, first_time = SDL_TRUE;
SDL_Cursor *cursor[3];
SDL_Cursor *cursor[4];
int current;
/* Load the SDL library */
@ -189,6 +189,7 @@ main(int argc, char *argv[])
SDL_Quit();
return (1);
}
cursor[3] = SDL_GetCursor();
current = 0;
SDL_SetCursor(cursor[current]);
@ -198,7 +199,7 @@ main(int argc, char *argv[])
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_MOUSEBUTTONDOWN:
current = (current + 1) % 3;
current = (current + 1) % SDL_arraysize(cursor);
SDL_SetCursor(cursor[current]);
break;
case SDL_KEYDOWN:
@ -222,3 +223,5 @@ main(int argc, char *argv[])
SDL_Quit();
return (0);
}
/* vi: set ts=4 sw=4 expandtab: */