previous | start | next

## Mouse Events

- In the notification functions, you can query the `wxMouseEvent` about the event type (e.g. `ButtonDown()` returns `true` or `false`, `GetX()` returns the x-position of the mouse, etc.).

  >     void TriangleWindow::OnMouseEvent(wxMouseEvent& event)
  >     {
  >        if (event.ButtonDown() && corners < 3)
  >        {
  >           x[corners] = event.GetX();
  >           y[corners] = event.GetY();
  >           corners++;
  >           Refresh();
  >        }
  >     }

- In our program, we allow the user to specify a triangle by clicking on the three corners.
- With each press, we record the mouse position.
- All drawing should happen in the paint handler.
- The `Refresh` function generates a paint event, which eventually causes the paint function to be called.
- Calling the paint function directly should never be done - always refresh instead.

previous | start | next