Index: binaries/data/mods/public/gui/session/input.js =================================================================== --- binaries/data/mods/public/gui/session/input.js +++ binaries/data/mods/public/gui/session/input.js @@ -42,10 +42,6 @@ // Number of pixels the mouse can move before the action is considered a drag var maxDragDelta = 4; -// Time in milliseconds in which a double click is recognized -const doubleClickTime = 500; -var doubleClickTimer = 0; -var doubleClicked = false; // Store the previously clicked entity - ensure a double/triple click happens on the same entity var prevClickedEntity = 0; @@ -966,7 +962,7 @@ { var ents = []; var selectedEntity = Engine.PickEntityAtPoint(ev.x, ev.y); - if (selectedEntity == INVALID_ENTITY) + if (selectedEntity == INVALID_ENTITY && ev.clicks == 1) { if (!Engine.HotkeyIsPressed("selection.add") && !Engine.HotkeyIsPressed("selection.remove")) { @@ -977,8 +973,6 @@ return true; } - var now = new Date(); - // If camera following and we select different unit, stop if (Engine.GetFollowedEntity() != selectedEntity) { @@ -985,7 +979,7 @@ Engine.CameraFollow(0); } - if (now.getTime() - doubleClickTimer < doubleClickTime && selectedEntity == prevClickedEntity) + if (ev.clicks >= 2) { // Double click or triple click has occurred var showOffscreen = Engine.HotkeyIsPressed("selection.offscreen"); @@ -993,25 +987,22 @@ var templateToMatch; // Check for double click or triple click - if (!doubleClicked) + if (ev.clicks == 2) { // If double click hasn't already occurred, this is a double click. // Select similar units regardless of rank - templateToMatch = GetEntityState(selectedEntity).identity.selectionGroupName; + templateToMatch = GetEntityState(prevClickedEntity).identity.selectionGroupName; if (templateToMatch) matchRank = false; else // No selection group name defined, so fall back to exact match - templateToMatch = GetEntityState(selectedEntity).template; + templateToMatch = GetEntityState(prevClickedEntity).template; - doubleClicked = true; - // Reset the timer so the user has an extra period 'doubleClickTimer' to do a triple-click - doubleClickTimer = now.getTime(); } else - // Double click has already occurred, so this is a triple click. + // triple click. // Select units matching exact template name (same rank) - templateToMatch = GetEntityState(selectedEntity).template; + templateToMatch = GetEntityState(prevClickedEntity).template; // TODO: Should we handle "control all units" here as well? ents = Engine.PickSimilarPlayerEntities(templateToMatch, showOffscreen, matchRank, false); @@ -1019,8 +1010,6 @@ else { // It's single click right now but it may become double or triple click - doubleClicked = false; - doubleClickTimer = now.getTime(); prevClickedEntity = selectedEntity; // We only want to include the first picked unit in the selection Index: source/gui/scripting/GuiScriptConversions.cpp =================================================================== --- source/gui/scripting/GuiScriptConversions.cpp +++ source/gui/scripting/GuiScriptConversions.cpp @@ -102,6 +102,7 @@ SET(obj, "state", (int)val.ev.button.state); SET(obj, "x", (int)val.ev.button.x); SET(obj, "y", (int)val.ev.button.y); + SET(obj, "clicks", (int)val.ev.button.clicks); break; } case SDL_HOTKEYDOWN: