Skip to content

Commit

Permalink
Script API: GUIMouseUp and Down events have click position as relative
Browse files Browse the repository at this point in the history
There are two considerations for this:
- The events refer to a mouse event over a particular GUI, not all or any gui, so it does not make much sense to have pos in screen coordinates.
- In theory, gui's position may also change between recording a mouse event in the engine and script function call.
  • Loading branch information
ivan-mogilko committed Dec 29, 2024
1 parent c824542 commit 1cc1f65
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Engine/ac/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ void gui_on_mouse_up(const int wasongui, const int wasbutdown, const int mx, con
break;
}

run_on_event(kScriptEvent_GUIMouseUp, wasongui, wasbutdown, mx, my);
run_on_event(kScriptEvent_GUIMouseUp, wasongui, wasbutdown, mx - guis[wasongui].X, my - guis[wasongui].Y);
}

void gui_on_mouse_down(const int guin, const int mbut, const int mx, const int my)
Expand All @@ -785,7 +785,7 @@ void gui_on_mouse_down(const int guin, const int mbut, const int mx, const int m
if ((guis[guin].MouseDownCtrl < 0) && (!guis[guin].OnClickHandler.IsEmpty()))
force_event(AGSEvent_GUI(guin, -1, static_cast<eAGSMouseButton>(mbut)));

run_on_event(kScriptEvent_GUIMouseDown, guin, mbut, mx, my);
run_on_event(kScriptEvent_GUIMouseDown, guin, mbut, mx - guis[guin].X, my - guis[guin].Y);
}

//=============================================================================
Expand Down

0 comments on commit 1cc1f65

Please sign in to comment.