Generate a synthetic event at a given axes coordinate. This method is intended for creating events during testing. The event can be emitted by calling its ``_process()`` method.
(cls, name, ax, xy, key, *args, **kwargs)
| 1532 | |
| 1533 | @classmethod |
| 1534 | def _from_ax_coords(cls, name, ax, xy, key, *args, **kwargs): |
| 1535 | """ |
| 1536 | Generate a synthetic event at a given axes coordinate. |
| 1537 | |
| 1538 | This method is intended for creating events during testing. The event |
| 1539 | can be emitted by calling its ``_process()`` method. |
| 1540 | """ |
| 1541 | # Separate from MouseEvent._from_ax_coords instead of being defined in the base |
| 1542 | # class, due to different parameter order in the constructor signature. |
| 1543 | x, y = ax.transData.transform(xy) |
| 1544 | event = cls(name, ax.figure.canvas, key, x, y, *args, **kwargs) |
| 1545 | event.inaxes = ax |
| 1546 | event.xdata, event.ydata = xy # Force exact xy to avoid fp roundtrip issues. |
| 1547 | return event |
| 1548 | |
| 1549 | |
| 1550 | # Default callback for key events. |