MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / HandleMouseDragDrop

Function HandleMouseDragDrop

src/window.cpp:1960–1981  ·  view source on GitHub ↗

* Handle dragging and dropping in mouse dragging mode (#WSM_DRAGDROP). * @return State of handling the event. */

Source from the content-addressed store, hash-verified

1958 * @return State of handling the event.
1959 */
1960static EventState HandleMouseDragDrop()
1961{
1962 if (_special_mouse_mode != WSM_DRAGDROP) return ES_NOT_HANDLED;
1963
1964 if (_left_button_down && _cursor.delta.x == 0 && _cursor.delta.y == 0) return ES_HANDLED; // Dragging, but the mouse did not move.
1965
1966 Window *w = _thd.GetCallbackWnd();
1967 if (w != nullptr) {
1968 /* Send an event in client coordinates. */
1969 Point pt;
1970 pt.x = _cursor.pos.x - w->left;
1971 pt.y = _cursor.pos.y - w->top;
1972 if (_left_button_down) {
1973 w->OnMouseDrag(pt, GetWidgetFromPos(w, pt.x, pt.y));
1974 } else {
1975 w->OnDragDrop(pt, GetWidgetFromPos(w, pt.x, pt.y));
1976 }
1977 }
1978
1979 if (!_left_button_down) ResetObjectToPlace(); // Button released, finished dragging.
1980 return ES_HANDLED;
1981}
1982
1983/** Report position of the mouse to the underlying window. */
1984static void HandleMouseOver()

Callers 1

MouseLoopFunction · 0.85

Calls 5

GetWidgetFromPosFunction · 0.85
ResetObjectToPlaceFunction · 0.85
GetCallbackWndMethod · 0.80
OnMouseDragMethod · 0.45
OnDragDropMethod · 0.45

Tested by

no test coverage detected