Skip to content
ExamplesOpen editor ↗

pebaETobeditswe

→ mousePressed()

Runs once when a mouse button is pressed down.

tiro pebaETobeditswe() { ... }

Declare pebaETobeditswe as a function with tiro, and Bopa will call it for you whenever a mouse button goes down. You never call it yourself.

It runs once per press — not once per frame the way tshwantsha does. If you want something to happen for the whole time a button is held, read konopoETshwerwe inside tshwantsha instead.

pebaX and pebaY are updated before pebaETobeditswe is called, so you can read them straight away.

On a phone, a finger does the mouse’s job. Bopa folds touch into the same pointer events. When your sketch is opened on a phone or a tablet, pebaETobeditswe runs the moment a finger touches the screen. The sketch you write here works on a phone and on the school computer without changing a line.

On a page element, use dirisaMoGo(e, pebaETobeditswe, handler) to register a press callback; pass maaka to remove it. The callback receives the native event and element this binding.

Click to drop a dot
tiro setaLoeto() {
  thalaKanefase(400, 260);
  bokamorago(238);
  tlogelaMothalo();
  tlhalosa('Kanefase e e bosetlha, mme sediko se sesha se tsenngwa fa o tobetsa.');
}

tiro pebaETobeditswe() {
  tlatsaMmala(paloEpe(80, 240), 90, 160, 180);
  thalaSediko(pebaX, pebaY, 46);
}

pebaEGolotswe, pebaEKonyilwe, konopoETshwerwe, pebaX, pebaY