MCPcopy Create free account
hub / github.com/BespokeSynth/BespokeSynth / KeyPressed

Method KeyPressed

Source/Push2Control.cpp:260–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

258}
259
260void Push2Control::KeyPressed(int key, bool isRepeat)
261{
262 if (key == OF_KEY_DOWN || key == OF_KEY_UP || key == OF_KEY_LEFT || key == OF_KEY_RIGHT)
263 {
264 for (int i = 0; i < (int)mModuleGridManualCables.size(); ++i)
265 {
266 if (mModuleGridManualCables[i]->IsHovered())
267 {
268 int x = i % 8;
269 int y = i / 8;
270 int newX = x;
271 int newY = y;
272 if (key == OF_KEY_RIGHT)
273 newX = ofClamp(x + 1, 0, 7);
274 if (key == OF_KEY_LEFT)
275 newX = ofClamp(x - 1, 0, 7);
276 if (key == OF_KEY_UP)
277 newY = ofClamp(y - 1, 0, 7);
278 if (key == OF_KEY_DOWN)
279 newY = ofClamp(y + 1, 0, 7);
280
281 IClickable* target = mModuleGridManualCables[x + y * 8]->GetTarget();
282 mModuleGridManualCables[x + y * 8]->ClearPatchCables();
283 mModuleGridManualCables[newX + newY * 8]->SetTarget(target);
284 }
285 }
286 }
287}
288
289void Push2Control::OnClicked(float x, float y, bool right)
290{

Callers

nothing calls this directly

Calls 6

ofClampFunction · 0.85
sizeMethod · 0.80
ClearPatchCablesMethod · 0.80
IsHoveredMethod · 0.45
GetTargetMethod · 0.45
SetTargetMethod · 0.45

Tested by

no test coverage detected