- if(state == BUTTON_DEACTIVE)
- return;
-
- SDLKey key = event.key.keysym.sym;
-
- if(event.type == SDL_MOUSEBUTTONDOWN || event.type == SDL_MOUSEBUTTONUP)
- {
- if(event.button.x < rect.x || event.button.x >= rect.x + rect.w ||
- event.button.y < rect.y || event.button.y >= rect.y + rect.h)
- return;
-
- if(event.button.button == SDL_BUTTON_RIGHT)
- {
- show_info = true;
- return;
- }
- else if(event.type == SDL_MOUSEBUTTONUP && event.button.button == 4) /* Mouse wheel up. */
- {
- state = BUTTON_WHEELUP;
- return;
- }
- else if(event.type == SDL_MOUSEBUTTONUP && event.button.button == 5) /* Mouse wheel down. */
- {
- state = BUTTON_WHEELDOWN;
- return;
- }
-
- if(event.button.button == SDL_BUTTON_LEFT)
- if(event.type == SDL_MOUSEBUTTONDOWN)
- state = BUTTON_PRESSED;
- else
- state = BUTTON_CLICKED;
- }
- else if(event.type == SDL_MOUSEMOTION)
- {
- if(event.motion.x < rect.x || event.motion.x >= rect.x + rect.w ||
- event.motion.y < rect.y || event.motion.y >= rect.y + rect.h)
- {
- state = BUTTON_NONE;
- }
- else
- {
- state = BUTTON_HOVER;
- popup_timer.start(1500);
- }
-
- if(show_info)
- {
- show_info = false;
- }
- }
- else if(event.type == SDL_KEYDOWN)
- {
- if(key == shortcut)
- state = BUTTON_PRESSED;
- }
- else if(event.type == SDL_KEYUP)
- {
- if(state == BUTTON_PRESSED && key == shortcut)
- state = BUTTON_CLICKED;
- }