Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_HoverDetectorComponent.c
Go to the documentation of this file.
1 
8 {
9  ref ScriptInvoker<SCR_HoverDetectorComponent, Widget> m_OnHoverDetected = new ScriptInvoker();
10  ref ScriptInvoker<SCR_HoverDetectorComponent, Widget> m_OnMouseLeave = new ScriptInvoker();
11 
12  [Attribute("200", desc: "Time between mouse entering widget and event activation, in milliseconds")]
13  protected float m_fHoverDelayMs;
14 
15  [Attribute("0", desc: "Triggers OnHover when the widget is focused instead of just on mouse enter")]
16  protected bool m_bDetectFocus;
17 
18  protected bool m_bMouseOver;
19 
20  //------------------------------------------------------------------------------------------------
21  override bool OnMouseEnter(Widget w, int x, int y)
22  {
23  m_bMouseOver = true;
24  auto callQueue = GetGame().GetCallqueue();
25  callQueue.Remove(OnTimer);
26  callQueue.CallLater(OnTimer, m_fHoverDelayMs);
27  return false;
28  }
29 
30  //------------------------------------------------------------------------------------------------
31  override bool OnMouseLeave(Widget w, Widget enterW, int x, int y)
32  {
33  m_bMouseOver = false;
34  auto callQueue = GetGame().GetCallqueue();
35  callQueue.Remove(OnTimer);
36  m_OnMouseLeave.Invoke(this, m_wRoot);
37  return false;
38  }
39 
40  //------------------------------------------------------------------------------------------------
41  override bool OnFocus(Widget w, int x, int y)
42  {
43  bool onFocus = super.OnFocus(w, x, y);
44 
45  if (m_bDetectFocus)
46  return OnMouseEnter(w, x, y);
47  else
48  return onFocus;
49  }
50 
51  //------------------------------------------------------------------------------------------------
52  override bool OnFocusLost(Widget w, int x, int y)
53  {
54  bool onFocusLost = super.OnFocusLost(w, x, y);
55 
56  if (m_bDetectFocus)
57  return OnMouseLeave(w, null, x, y);
58  else
59  return onFocusLost;
60  }
61 
62  //------------------------------------------------------------------------------------------------
63  void OnTimer()
64  {
65  // Invoke event if cursor is still over this widget
66  if (m_bMouseOver)
67  OnHoverDetected();
68  }
69 
70  //------------------------------------------------------------------------------------------------
71  protected void OnHoverDetected()
72  {
73  m_OnHoverDetected.Invoke(this, m_wRoot);
74  }
75 
76  //------------------------------------------------------------------------------------------------
77  static SCR_HoverDetectorComponent FindComponent(Widget w)
78  {
79  return SCR_HoverDetectorComponent.Cast(w.FindHandler(SCR_HoverDetectorComponent));
80  }
81 };
m_wRoot
protected Widget m_wRoot
Definition: SCR_ScenarioFrameworkLayerTaskDefend.c:59
SCR_HoverDetectorComponent
Definition: SCR_HoverDetectorComponent.c:7
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
desc
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition: SCR_RespawnBriefingComponent.c:17
Attribute
typedef Attribute
Post-process effect of scripted camera.
m_bMouseOver
protected bool m_bMouseOver
Definition: SCR_ModularButtonComponent.c:75
SCR_ScriptedWidgetComponent
Definition: SCR_ScriptedWidgetComponent.c:7
m_OnMouseLeave
ref ScriptInvoker m_OnMouseLeave
Definition: SCR_ModularButtonComponent.c:66