Class 708 – Mouse Events (onMousePress / onMouseRelease)

Make programs respond to user clicks

Today's Goals

  • Understand what mouse events are and why they matter
  • Write onMousePress and onMouseRelease event handlers
  • Use mouse coordinates (mouseX, mouseY) in programs
  • Make interactive programs that respond to clicks

Agenda

  • Review functions with parameters
  • Introduction to events and interactivity
  • Teacher demo: onMousePress and onMouseRelease
  • Guided practice with mouse coordinates
  • CMU CS Academy practice time

What You Must Finish Today

  • Complete the CMU CS Academy exercises on mouse events
  • Practice using onMousePress and onMouseRelease handlers
  • Build at least one interactive program using mouse coordinates

Homework

Finish any remaining CMU mouse event exercises from today

Quick Reminder

  • Events make programs interactive – they let your code respond to user actions!
  • Mouse events are triggered by clicking, not by running the program.
  • Use mouseX and mouseY to find out where the user clicked.