MCPcopy Index your code
hub / github.com/EmulatorJS/EmulatorJS / addButton

Method addButton

data/src/emulator.js:1426–1444  ·  view source on GitHub ↗
(title, hidden, functi0n)

Source from the content-addressed store, hash-verified

1424 this.addEventListener(this.game, "mousedown touchend", hideMenu);
1425 const parent = this.createElement("ul");
1426 const addButton = (title, hidden, functi0n) => {
1427 //<li><a href="#" onclick="return false">'+title+'</a></li>
1428 const li = this.createElement("li");
1429 if (hidden) li.hidden = true;
1430 const a = this.createElement("a");
1431 if (functi0n instanceof Function) {
1432 this.addEventListener(li, "click", (e) => {
1433 e.preventDefault();
1434 functi0n();
1435 });
1436 }
1437 a.href = "#";
1438 a.onclick = "return false";
1439 a.innerText = this.localization(title);
1440 li.appendChild(a);
1441 parent.appendChild(li);
1442 hideMenu();
1443 return li;
1444 }
1445 let screenshotUrl;
1446 const screenshot = addButton("Take Screenshot", false, () => {
1447 if (screenshotUrl) URL.revokeObjectURL(screenshotUrl);

Callers

nothing calls this directly

Calls 3

createElementMethod · 0.95
addEventListenerMethod · 0.95
localizationMethod · 0.95

Tested by

no test coverage detected