From 90beda96f8bf1ad949936ea13504d8e637a9e98d Mon Sep 17 00:00:00 2001 From: elexis Date: Tue, 16 May 2017 00:09:16 +0000 Subject: [PATCH] Fix atlas clicking following 8f36ca47a1 / D326 by adding the missing clicks property to the wxWidgets SDL event construction. Differential Revision: https://code.wildfiregames.com/D452 Fixes #4557 Patch By: causative This was SVN commit r19589. --- .../atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp | 12 ++++++++++-- .../atlas/GameInterface/Handlers/MiscHandlers.cpp | 3 ++- source/tools/atlas/GameInterface/Messages.h | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp b/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp index b62abfdfca..5198c73492 100644 --- a/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp +++ b/source/tools/atlas/AtlasUI/ScenarioEditor/ScenarioEditor.cpp @@ -51,6 +51,11 @@ static HighResTimer g_Timer; +/** + * wxWidgets only registers the double click on mousedown. + */ +static int g_Clicks = 1; + using namespace AtlasMessage; ////////////////////////////////////////////////////////////////////////// @@ -272,9 +277,12 @@ private: // Button down and double click appear to be mutually exclusive events, // meaning a second button down event is not sent before a double click if (evt.ButtonDown() || evt.ButtonDClick()) - POST_MESSAGE(GuiMouseButtonEvent, (evt.GetButton(), true, evt.GetPosition())); + { + g_Clicks = evt.ButtonDClick() ? 2 : 1; + POST_MESSAGE(GuiMouseButtonEvent, (evt.GetButton(), true, evt.GetPosition(), g_Clicks)); + } else if (evt.ButtonUp()) - POST_MESSAGE(GuiMouseButtonEvent, (evt.GetButton(), false, evt.GetPosition())); + POST_MESSAGE(GuiMouseButtonEvent, (evt.GetButton(), false, evt.GetPosition(), g_Clicks)); else if (evt.GetEventType() == wxEVT_MOTION) POST_MESSAGE(GuiMouseMotionEvent, (evt.GetPosition())); } diff --git a/source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp b/source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp index e9c485b046..567587a6da 100644 --- a/source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp +++ b/source/tools/atlas/GameInterface/Handlers/MiscHandlers.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Wildfire Games. +/* Copyright (C) 2017 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -170,6 +170,7 @@ MESSAGEHANDLER(GuiMouseButtonEvent) ev.ev.type = msg->pressed ? SDL_MOUSEBUTTONDOWN : SDL_MOUSEBUTTONUP; ev.ev.button.button = msg->button; ev.ev.button.state = msg->pressed ? SDL_PRESSED : SDL_RELEASED; + ev.ev.button.clicks = msg->clicks; float x, y; msg->pos->GetScreenSpace(x, y); ev.ev.button.x = (u16)clamp((int)x, 0, g_xres); diff --git a/source/tools/atlas/GameInterface/Messages.h b/source/tools/atlas/GameInterface/Messages.h index 54ddde0813..cc2247acb2 100644 --- a/source/tools/atlas/GameInterface/Messages.h +++ b/source/tools/atlas/GameInterface/Messages.h @@ -90,6 +90,7 @@ MESSAGE(GuiMouseButtonEvent, ((int, button)) ((bool, pressed)) ((Position, pos)) + ((int, clicks)) ); MESSAGE(GuiMouseMotionEvent,