joulupunikki / Phoenix

Java clone/remake/patch of the game Emperor of the Fading Suns
https://joulupunikki.github.io/Phoenix/
37 stars 14 forks source link

Use of mousePressed() considered harmfull ? #48

Open joulupunikki opened 8 years ago

joulupunikki commented 8 years ago

On SpaceMap space_map in Gui, mousePressed is used to trigger input events. When this is combined with the event triggering a JDialog which is not under the mouse cursor, the mouse release event is not registered by the event logging code in Phoenix. Also, when the input is replayed by RobotTester, even if the lost event is manually inserted, the test will fail. Presumably there is an issue with the JDialog and the mouse release contesting for focus. On Windows 7 this will also cause os level input problems until a release of the pressed mouse button is registered, eg. by clicking the button.

This does not appear to cause problems during normal game play, only event logging and RobotTester replay are affected.

SUGGESTED FIX: If mousePressed() is replaced with mouseClicked() the release event will register in Phoenix event logging code and when replayed with RobotTester the test will succeed.

15.10.2015: Well, this shows up on PlanetMap too, and changing mousePressed() to mouseClicked() fixes it, but java is very sensitive regarding mouse pointer movement between press and release so clicks have harder time registering.

20.5.2016: Using mouseClicked() without any compensation makes fast play impossible, a workaround must be found, even if it means giving up accurate event logging.