3 [
Attribute(
"1",
desc:
"When enabled, action will not be performed if its shotcut is mouse double-click and mouse moved between two clicks.")]
4 protected bool m_bIsDoubleClick;
6 protected const string LMB_ACTION =
"MouseLeft";
7 protected const int MAX_CURSOR_DIST_SQ = 100;
9 protected vector m_vMouseLeftPos;
11 protected void CachePosition()
13 m_vMouseLeftPos = GetMousePosVector();
15 protected void OnLMB()
17 GetGame().GetCallqueue().CallLater(CachePosition, 1);
19 protected vector GetMousePosVector()
22 WidgetManager.GetMousePos(mouseX, mouseY);
23 return Vector(mouseX, mouseY, 0);
25 protected bool DidCursorMoveDuringDoubleClick()
27 if (!m_bIsDoubleClick || !
GetGame().
GetInputManager().IsUsingMouseAndKeyboard() || m_vMouseLeftPos == vector.Zero)
30 bool didMove = vector.DistanceSq(m_vMouseLeftPos, GetMousePosVector()) > MAX_CURSOR_DIST_SQ;
31 m_vMouseLeftPos = vector.Zero;
35 override void AddShortcut(SCR_BaseActionsEditorComponent actionsManager)
37 super.AddShortcut(actionsManager);
40 GetGame().GetInputManager().AddActionListener(LMB_ACTION, EActionTrigger.DOWN, OnLMB);
42 override void RemoveShortcut()
45 GetGame().GetInputManager().RemoveActionListener(LMB_ACTION, EActionTrigger.DOWN, OnLMB);
47 super.RemoveShortcut();