* Called every time there's a keyboard press when the surface is focused. * Allows the surface to have custom functionality for this action, * and can be called externally to simulate the action. * @param action Pointer to an action. * @param state State that the action handlers belong to. */
| 360 | * @param state State that the action handlers belong to. |
| 361 | */ |
| 362 | void InteractiveSurface::keyboardPress(Action *action, State *state) |
| 363 | { |
| 364 | std::map<SDLKey, ActionHandler>::iterator allHandler = _keyPress.find(SDLK_ANY); |
| 365 | std::map<SDLKey, ActionHandler>::iterator oneHandler = _keyPress.find(action->getDetails()->key.keysym.sym); |
| 366 | if (allHandler != _keyPress.end()) |
| 367 | { |
| 368 | ActionHandler handler = allHandler->second; |
| 369 | (state->*handler)(action); |
| 370 | } |
| 371 | // Check if Ctrl, Alt and Shift aren't pressed |
| 372 | bool mod = ((action->getDetails()->key.keysym.mod & (KMOD_CTRL|KMOD_ALT|KMOD_SHIFT)) != 0); |
| 373 | if (oneHandler != _keyPress.end() && !mod) |
| 374 | { |
| 375 | ActionHandler handler = oneHandler->second; |
| 376 | (state->*handler)(action); |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | /** |
| 381 | * Called every time there's a keyboard release over the surface. |
nothing calls this directly
no test coverage detected