MCPcopy Create free account
hub / github.com/OpenXcom/OpenXcom / mousePress

Method mousePress

src/Interface/ScrollBar.cpp:188–212  ·  view source on GitHub ↗

* The scrollbar only moves while the button is pressed. * @param action Pointer to an action. * @param state State that the action handlers belong to. */

Source from the content-addressed store, hash-verified

186 * @param state State that the action handlers belong to.
187 */
188void 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.

Callers

nothing calls this directly

Calls 4

getDetailsMethod · 0.80
getAbsoluteYMouseMethod · 0.80
scrollUpMethod · 0.80
scrollDownMethod · 0.80

Tested by

no test coverage detected