while (1) { SDL_Event event; Delay();  Mouse::mouse->hide(); Mouse::mouse_update = false;  while (SDL_PollEvent(&event)) switch (event.type) { case SDL_MOUSEBUTTONUP: if (event.button.button == 1) { x = event.button.x >> scale; y = event.button.y >> scale; if (chr) *chr = 0; return (1); }  else if (event.button.button == 3)  gwin->get_main_actor()->stop(); break; case SDL_MOUSEMOTION: Mouse::mouse->move(event.motion.x >> scale, event.motion.y >> scale); Mouse::mouse_update = true; break; case SDL_KEYDOWN: {  int c = event.key.keysym.sym; switch(c) { case SDLK_ESCAPE: return 0; case SDLK_RSHIFT: case SDLK_LSHIFT: case SDLK_RCTRL: case SDLK_LCTRL: case SDLK_RALT: case SDLK_LALT: case SDLK_RMETA: case SDLK_LMETA: case SDLK_RSUPER: case SDLK_LSUPER: case SDLK_NUMLOCK: case SDLK_CAPSLOCK: case SDLK_SCROLLOCK: break; default: if ((c == 's') && (event.key.keysym.mod & KMOD_ALT) && (event.key.keysym.mod & KMOD_CTRL)){ make_screenshot(true); break; } if (chr) { *chr = (event.key.keysym.mod & KMOD_SHIFT) ? toupper(c) : c; return (1); } break; } break; } case SDL_ACTIVEEVENT: if (event.active.state & SDL_APPINPUTFOCUS) { if (event.active.gain) gwin->get_focus(); else gwin->lose_focus(); } } Mouse::mouse->show();  if (!gwin->show() && Mouse::mouse_update) Mouse::mouse->blit_dirty(); } return (0);
if (chr) *chr = 0; Mouse::Mouse_shapes saveshape = Mouse::mouse->get_shape(); if (shape != Mouse::dontchange) Mouse::mouse->set_shape(shape); Mouse::mouse->show(); gwin->show(1); int ret = Get_click(x, y, chr); Mouse::mouse->set_shape(saveshape); return (ret);
static int Get_click	(	int& x, int& y,	char *chr			// Char. returned if not null.	)	{	while (1)		{		SDL_Event event;		Delay();		// Wait a fraction of a second.		Mouse::mouse->hide();		// Turn off mouse.		Mouse::mouse_update = false;		while (SDL_PollEvent(&event))			switch (event.type)				{			case SDL_MOUSEBUTTONUP:				if (event.button.button == 1)					{					x = event.button.x >> scale;					y = event.button.y >> scale;					if (chr) *chr = 0;					return (1);					}					// May have been moving before.				else if (event.button.button == 3)					// Just stop.  Don't get followers!					gwin->get_main_actor()->stop();				break;			case SDL_MOUSEMOTION:				Mouse::mouse->move(event.motion.x >> scale, 						event.motion.y >> scale);				Mouse::mouse_update = true;				break;			case SDL_KEYDOWN:				{				//+++++ convert to unicode first?				int c = event.key.keysym.sym;				switch(c) {				case SDLK_ESCAPE:					return 0;				case SDLK_RSHIFT: case SDLK_LSHIFT:				case SDLK_RCTRL: case SDLK_LCTRL:				case SDLK_RALT: case SDLK_LALT:				case SDLK_RMETA: case SDLK_LMETA:				case SDLK_RSUPER: case SDLK_LSUPER:				case SDLK_NUMLOCK: case SDLK_CAPSLOCK:				case SDLK_SCROLLOCK:					break;				default:					if ((c == 's') &&  					   (event.key.keysym.mod & KMOD_ALT) &&					   (event.key.keysym.mod & KMOD_CTRL)){						make_screenshot(true);						break;					}					if (chr)// Looking for a character?					{						*chr = (event.key.keysym.mod & 							KMOD_SHIFT)							? toupper(c) : c;						return (1);					}					break;				}				break;				}			case SDL_ACTIVEEVENT:				if (event.active.state & SDL_APPINPUTFOCUS)					{					if (event.active.gain)						gwin->get_focus();					else						gwin->lose_focus();					}				}		Mouse::mouse->show();		// Turn on mouse.		if (!gwin->show() &&	// Blit to screen if necessary.		    Mouse::mouse_update)			Mouse::mouse->blit_dirty();		}	return (0);			// Shouldn't get here.	}