MCPcopy Create free account
hub / github.com/google-deepmind/dm_control / process

Method process

dm_control/viewer/gui/base.py:68–89  ·  view source on GitHub ↗

Attempts to identify a mouse button click as a double click event.

(self, button, action)

Source from the content-addressed store, hash-verified

66 self._double_clicks = {}
67
68 def process(self, button, action):
69 """Attempts to identify a mouse button click as a double click event."""
70 if action != user_input.PRESS:
71 return False
72
73 curr_time = time.time()
74 timestamp = self._double_clicks.get(button, None)
75 if timestamp is None:
76 # No previous click registered.
77 self._double_clicks[button] = curr_time
78 return False
79 else:
80 time_elapsed = curr_time - timestamp
81 if time_elapsed < _DOUBLE_CLICK_INTERVAL:
82 # Double click discovered.
83 self._double_clicks[button] = None
84 return True
85 else:
86 # The previous click was too long ago, so discard it and start a fresh
87 # timer.
88 self._double_clicks[button] = curr_time
89 return False

Calls 2

timeMethod · 0.45
getMethod · 0.45