Skip to content

Commit 945f3d1

Browse files
committed
Moar keyboard shortcuts
See readme Issue #17
1 parent d9313a3 commit 945f3d1

File tree

3 files changed

+92
-3
lines changed

3 files changed

+92
-3
lines changed

InteractiveHtmlBom/ibom.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,9 @@
102102
<div id="bot" class="split" style="height: calc(100% - 80px)">
103103
<div id="bomdiv" class="split split-horizontal">
104104
<div style="width: 100%">
105-
<input class="searchbox reflookup hideonprint" type="text" placeholder="Ref lookup"
105+
<input id="reflookup" class="searchbox reflookup hideonprint" type="text" placeholder="Ref lookup"
106106
oninput="updateRefLookup(this.value)">
107-
<input class="searchbox filter hideonprint" type="text" placeholder="Filter"
107+
<input id="filter" class="searchbox filter hideonprint" type="text" placeholder="Filter"
108108
oninput="updateFilter(this.value)">
109109
</div>
110110
<div id="dbg"></div>

InteractiveHtmlBom/ibom.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ var bomlayout = "default";
99
var currentHighlightedRowId;
1010
var highlightHandlers = [];
1111
var highlightedRefs = [];
12+
var checkboxes = [];
1213
var bomCheckboxes = "";
1314
var storage;
1415

@@ -475,6 +476,31 @@ function changeBomLayout(layout) {
475476
changeCanvasLayout(canvaslayout);
476477
}
477478

479+
function focusInputField(input) {
480+
input.scrollIntoView(false);
481+
input.focus();
482+
input.select();
483+
}
484+
485+
function focusFilterField() {
486+
focusInputField(document.getElementById("filter"));
487+
}
488+
489+
function focusRefLookupField() {
490+
focusInputField(document.getElementById("reflookup"));
491+
}
492+
493+
function toggleBomCheckbox(bomrowid, checkboxnum) {
494+
if (!bomrowid || checkboxnum > checkboxes.length) {
495+
return;
496+
}
497+
var bomrow = document.getElementById(bomrowid);
498+
var checkbox = bomrow.childNodes[checkboxnum].childNodes[0];
499+
checkbox.checked = !checkbox.checked;
500+
checkbox.indeterminate = false;
501+
checkbox.onchange();
502+
}
503+
478504
function removeGutterNode(node) {
479505
for (var i = 0; i < node.childNodes.length; i++) {
480506
if (node.childNodes[i].classList &&
@@ -509,6 +535,47 @@ document.onkeydown = function(e) {
509535
default:
510536
break;
511537
}
538+
if (e.altKey) {
539+
switch (e.key) {
540+
case "f":
541+
focusFilterField();
542+
e.preventDefault();
543+
break;
544+
case "r":
545+
focusRefLookupField();
546+
e.preventDefault();
547+
break;
548+
case "z":
549+
changeBomLayout("BOM");
550+
e.preventDefault();
551+
break;
552+
case "x":
553+
changeBomLayout("LR");
554+
e.preventDefault();
555+
break;
556+
case "c":
557+
changeBomLayout("TB");
558+
e.preventDefault();
559+
break;
560+
case "v":
561+
changeCanvasLayout("F");
562+
e.preventDefault();
563+
break;
564+
case "b":
565+
changeCanvasLayout("FB");
566+
e.preventDefault();
567+
break;
568+
case "n":
569+
changeCanvasLayout("B");
570+
e.preventDefault();
571+
break;
572+
default:
573+
break;
574+
}
575+
if (e.key >= '1' && e.key <= '9') {
576+
toggleBomCheckbox(currentHighlightedRowId, parseInt(e.key));
577+
}
578+
}
512579
}
513580

514581
window.onload = function(e) {

README.md

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,28 @@ will look like this:
8787
path/to/kicad/bin/python.exe .../generate_interactive_bom.py .../board.kicad_pcb
8888
```
8989

90+
### BOM mouse actions
91+
92+
You can pan the pcb drawings using left mouse button, zoom using mouse wheel
93+
and reset view by right click.
94+
95+
### BOM keyboard shortcuts
96+
97+
Html page supports keyboard shortcuts to perform most tasks:
98+
99+
* `ArrowUp` / `ArrowDown` scroll through the bom table
100+
* `Alt-R` focuses reference lookup field
101+
* `Alt-F` focuses filter field
102+
* `Alt-Z` switches to bom only view
103+
* `Alt-X` switches to bom left, drawings right view
104+
* `Alt-C` switches to bom top, drawings bot view
105+
* `Alt-V` switches to front only view
106+
* `Alt-B` switches to front and back view
107+
* `Alt-N` switches to back only view
108+
* `Alt-1` through `Alt-9` toggle corresponding checkbox for highlighted bom row
109+
(if it exists)
110+
111+
90112
## Supported versions
91113

92114
KiCad 5.0 is the only fully supported version. Pcbnew python interface is not very
@@ -162,7 +184,7 @@ problem area._
162184
Generated html page is tested in Chrome and Firefox. IE will not be
163185
supported, patches for other browsers are welcome.
164186

165-
Edge is currently broken because of
187+
Edge works but saving settings/checkboxes is currently broken because of
166188
https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8816771/
167189

168190
# License and credits

0 commit comments

Comments
 (0)