while (1) { SDL_Event event; Delay(); #ifdef MOUSE mouse->hide(); #endif while (SDL_PollEvent(&event)) switch (event.type) { case SDL_MOUSEBUTTONUP: if (event.button.button == 1) { x = event.button.x; y = event.button.y; return (1); } break; case SDL_MOUSEMOTION: #ifdef MOUSE mouse->move(event.motion.x, event.motion.y); gwin->set_painted(); #endif break; case SDL_QUIT: quitting_time = 1; return (0); case SDL_KEYDOWN: if (event.key.keysym.sym == SDLK_ESCAPE) return (0); break; } #ifdef MOUSE mouse->show(); #endif gwin->show(); } return (0);
Mouse::Mouse_shapes saveshape = mouse->get_shape(); if (shape != Mouse::dontchange) mouse->set_shape(shape); int ret = Get_click(x, y); mouse->set_shape(saveshape); return (ret);
static int Get_click	(	int& x, int& y	)	{	while (1)		{		SDL_Event event;		Delay();		// Wait a fraction of a second.#ifdef MOUSE		mouse->hide();		// Turn off mouse.#endif		while (SDL_PollEvent(&event))			switch (event.type)				{			case SDL_MOUSEBUTTONUP:				if (event.button.button == 1)					{					x = event.button.x;					y = event.button.y;					return (1);					}				break;			case SDL_MOUSEMOTION:#ifdef MOUSE				mouse->move(event.motion.x, event.motion.y);				gwin->set_painted();#endif				break;			case SDL_QUIT:				quitting_time = 1;				return (0);			case SDL_KEYDOWN:				if (event.key.keysym.sym == SDLK_ESCAPE)					return (0);				break;				}#ifdef MOUSE		mouse->show();		// Turn on mouse.#endif		gwin->show();		// Blit to screen if necessary.		}	return (0);			// Shouldn't get here.	}