* The scrollbar only moves while the button is pressed. * @param action Pointer to an action. * @param state State that the action handlers belong to. */
| 186 | * @param state State that the action handlers belong to. |
| 187 | */ |
| 188 | void ScrollBar::mousePress(Action *action, State *state) |
| 189 | { |
| 190 | InteractiveSurface::mousePress(action, state); |
| 191 | if (action->getDetails()->button.button == SDL_BUTTON_LEFT) |
| 192 | { |
| 193 | int cursorY = action->getAbsoluteYMouse() - getY(); |
| 194 | if (cursorY >= _thumbRect.y && cursorY < _thumbRect.y + _thumbRect.h) |
| 195 | { |
| 196 | _offset = _thumbRect.y - cursorY; |
| 197 | } |
| 198 | else |
| 199 | { |
| 200 | _offset = -_thumbRect.h / 2; |
| 201 | } |
| 202 | _pressed = true; |
| 203 | } |
| 204 | else if (action->getDetails()->button.button == SDL_BUTTON_WHEELUP) |
| 205 | { |
| 206 | _list->scrollUp(false, true); |
| 207 | } |
| 208 | else if (action->getDetails()->button.button == SDL_BUTTON_WHEELDOWN) |
| 209 | { |
| 210 | _list->scrollDown(false, true); |
| 211 | } |
| 212 | } |
| 213 | |
| 214 | /** |
| 215 | * The scrollbar stops moving when the button is released. |
nothing calls this directly
no test coverage detected