mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-07 23:10:04 +00:00
(svn r21822) -Codechange: Merge event handling code.
This commit is contained in:
parent
4a203e8a49
commit
32cd182ecc
@ -1429,38 +1429,24 @@ static void HandlePlacePresize()
|
|||||||
*/
|
*/
|
||||||
static EventState HandleMouseDragDrop()
|
static EventState HandleMouseDragDrop()
|
||||||
{
|
{
|
||||||
Window *w;
|
|
||||||
|
|
||||||
if (_special_mouse_mode != WSM_DRAGDROP) return ES_NOT_HANDLED;
|
if (_special_mouse_mode != WSM_DRAGDROP) return ES_NOT_HANDLED;
|
||||||
|
|
||||||
if (_left_button_down && _cursor.delta.x == 0 && _cursor.delta.y == 0) return ES_HANDLED; // Dragging, but the mouse did not move.
|
if (_left_button_down && _cursor.delta.x == 0 && _cursor.delta.y == 0) return ES_HANDLED; // Dragging, but the mouse did not move.
|
||||||
if (!_left_button_down) goto handle_dragdop;
|
|
||||||
|
|
||||||
w = _thd.GetCallbackWnd();
|
|
||||||
|
|
||||||
|
Window *w = _thd.GetCallbackWnd();
|
||||||
if (w != NULL) {
|
if (w != NULL) {
|
||||||
/* Send an event in client coordinates. */
|
/* Send an event in client coordinates. */
|
||||||
Point pt;
|
Point pt;
|
||||||
pt.x = _cursor.pos.x - w->left;
|
pt.x = _cursor.pos.x - w->left;
|
||||||
pt.y = _cursor.pos.y - w->top;
|
pt.y = _cursor.pos.y - w->top;
|
||||||
|
if (_left_button_down) {
|
||||||
w->OnMouseDrag(pt, GetWidgetFromPos(w, pt.x, pt.y));
|
w->OnMouseDrag(pt, GetWidgetFromPos(w, pt.x, pt.y));
|
||||||
}
|
} else {
|
||||||
|
|
||||||
return ES_HANDLED;
|
|
||||||
|
|
||||||
handle_dragdop:
|
|
||||||
w = _thd.GetCallbackWnd();
|
|
||||||
|
|
||||||
if (w != NULL) {
|
|
||||||
/* send an event in client coordinates. */
|
|
||||||
Point pt;
|
|
||||||
pt.x = _cursor.pos.x - w->left;
|
|
||||||
pt.y = _cursor.pos.y - w->top;
|
|
||||||
w->OnDragDrop(pt, GetWidgetFromPos(w, pt.x, pt.y));
|
w->OnDragDrop(pt, GetWidgetFromPos(w, pt.x, pt.y));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ResetObjectToPlace();
|
if (!_left_button_down) ResetObjectToPlace(); // Button released, finished dragging.
|
||||||
|
|
||||||
return ES_HANDLED;
|
return ES_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user