MCPcopy Create free account
hub / github.com/audacity/audacity / OnKeyDown

Method OnKeyDown

src/widgets/KeyView.cpp:1416–1616  ·  view source on GitHub ↗

Handle the wxEVT_KEY_DOWN event

Source from the content-addressed store, hash-verified

1414// Handle the wxEVT_KEY_DOWN event
1415//
1416void
1417KeyView::OnKeyDown(wxKeyEvent & event)
1418{
1419 int line = GetSelection();
1420
1421 int keycode = event.GetKeyCode();
1422 switch (keycode)
1423 {
1424 // The LEFT key moves selection to parent or collapses selected
1425 // node if it is expanded.
1426 case WXK_LEFT:
1427 {
1428 // Nothing selected...nothing to do
1429 if (line == wxNOT_FOUND)
1430 {
1431 // Allow further processing
1432 event.Skip();
1433 break;
1434 }
1435
1436 KeyNode *node = mLines[line];
1437
1438 // Collapse the node if it is open
1439 if (node->isopen)
1440 {
1441 // No longer open
1442 node->isopen = false;
1443
1444 // Don't want the view to scroll vertically, so remember the current
1445 // top line.
1446 size_t topline = GetVisibleBegin();
1447
1448 // Refresh the view now that the number of lines have changed
1449 RefreshLines();
1450
1451 // Reset the original top line
1452 ScrollToRow(topline);
1453
1454 // And make sure current line is still selected
1455 SelectNode(LineToIndex(line));
1456 }
1457 else
1458 {
1459 // Move selection to the parent of this node
1460 for (int i = line - 1; i >= 0; i--)
1461 {
1462 // Found the parent
1463 if (mLines[i]->depth < node->depth)
1464 {
1465 // So select it
1466 SelectNode(LineToIndex(i));
1467 break;
1468 }
1469 }
1470 }
1471
1472 // Further processing of the event is not wanted
1473 // (we didn't call event.Skip()

Callers

nothing calls this directly

Calls 4

SkipMethod · 0.80
DisplayMethod · 0.80
sizeMethod · 0.45
IsSameAsMethod · 0.45

Tested by

no test coverage detected