MCPcopy Index your code
hub / github.com/pyfa-org/Pyfa / HandleMouseEvent

Method HandleMouseEvent

graphs/gui/vector.py:215–237  ·  view source on GitHub ↗
(self, event)

Source from the content-addressed store, hash-verified

213 self.SendChangeEvent()
214
215 def HandleMouseEvent(self, event):
216 width, height = self.GetClientSize()
217 if width and height:
218 center = min(width, height) / 2
219 x, y = event.GetPosition()
220 x = x - center
221 y = center - y
222 angle = self._angle
223 length = min((x ** 2 + y ** 2) ** 0.5 / (center - 2), 1.0)
224 if length < 0.01:
225 length = 0
226 else:
227 angle = ((math.degrees(math.atan2(y, x)) - self._offset + 180) % 360) - 180
228 if (self._right and not self._left) or event.ShiftDown():
229 angle = round(angle / 15.0) * 15.0
230 # floor() for length to make it easier to hit 0%, can still hit 100% outside the circle
231 length = math.floor(length / 0.05) * 0.05
232 if (angle != self._angle) or (length != self._length):
233 self._angle = angle
234 self._length = length
235 self.Refresh()
236 if (self._right and not self._left) or event.ShiftDown():
237 self.SendChangeEvent()
238
239 # Focus manipulation - otherwise scrolling doesn't work under Windows
240 def OnMouseMove(self, event):

Callers 5

OnLeftDownMethod · 0.95
OnRightDownMethod · 0.95
OnLeftUpMethod · 0.95
OnRightUpMethod · 0.95
OnMotionMethod · 0.95

Calls 3

SendChangeEventMethod · 0.95
GetPositionMethod · 0.45
RefreshMethod · 0.45

Tested by

no test coverage detected