mirror of
https://github.com/EmulatorJS/EmulatorJS.git
synced 2024-09-20 02:46:23 +00:00
Add button to open context menu (#728)
* Add button to open context menu In some contexts, it's hard or impossible to open the context menu of the emulator, which is required to access important secondary options such as quick states, screen recording, and software information. Primarily, it's apparently impossible to open the context menu on a mobile web browser, since a long press on the screen is, for good reason, not registered like a right mouse click is on desktop. This commit adds what I think is the ideal solution to the issue: a button on the menu bar/drawer that opens up the context menu, without cluttering it up with multiple options, just a single new one. * Update en locale (en.json, Translate.html) * Fix contextMenuButton dimensions * Set contextMenu to be centered when open via button
This commit is contained in:
parent
584ee6f1b9
commit
eea0ec3dc3
4 changed files with 14 additions and 1 deletions
|
@ -1788,6 +1788,16 @@ class EmulatorJS {
|
|||
}
|
||||
|
||||
this.elements.menu.appendChild(volumeSettings);
|
||||
|
||||
const contextMenuButton = addButton("Context Menu", '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><!--!Font Awesome Free 6.5.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2023 Fonticons, Inc.--><path d="M0 96C0 78.3 14.3 64 32 64H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32C14.3 128 0 113.7 0 96zM0 256c0-17.7 14.3-32 32-32H416c17.7 0 32 14.3 32 32s-14.3 32-32 32H32c-17.7 0-32-14.3-32-32zM448 416c0 17.7-14.3 32-32 32H32c-17.7 0-32-14.3-32-32s14.3-32 32-32H416c17.7 0 32 14.3 32 32z"/></svg>', () => {
|
||||
if (this.elements.contextmenu.style.display == "none") {
|
||||
this.elements.contextmenu.style.display = "block";
|
||||
this.elements.contextmenu.style.left = (getComputedStyle(this.elements.parent).width.split("px")[0]/2 - getComputedStyle(this.elements.contextmenu).width.split("px")[0]/2)+"px";
|
||||
this.elements.contextmenu.style.top = (getComputedStyle(this.elements.parent).height.split("px")[0]/2 - getComputedStyle(this.elements.contextmenu).height.split("px")[0]/2)+"px";
|
||||
} else {
|
||||
this.elements.contextmenu.style.display = "none";
|
||||
}
|
||||
});
|
||||
|
||||
this.settingParent = this.createElement("div");
|
||||
this.settingsMenuOpen = false;
|
||||
|
@ -1893,6 +1903,7 @@ class EmulatorJS {
|
|||
playPause: [pauseButton, playButton],
|
||||
restart: [restartButton],
|
||||
settings: [settingButton],
|
||||
contextMenu: [contextMenuButton],
|
||||
fullscreen: [enter, exit],
|
||||
saveState: [saveState],
|
||||
loadState: [loadState],
|
||||
|
|
2
data/emulator.min.js
vendored
2
data/emulator.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -42,6 +42,7 @@
|
|||
"Mute": "-Mute",
|
||||
"Unmute": "-Unmute",
|
||||
"Settings": "-Settings",
|
||||
"Context Menu": "-Context Menu",
|
||||
"Enter Fullscreen": "-Enter Fullscreen",
|
||||
"Exit Fullscreen": "-Exit Fullscreen",
|
||||
"Reset": "-Reset",
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
"Settings": "-Settings",
|
||||
"Enter Fullscreen": "-Enter Fullscreen",
|
||||
"Exit Fullscreen": "-Exit Fullscreen",
|
||||
"Context Menu": "-Context Menu",
|
||||
"Reset": "-Reset",
|
||||
"Clear": "-Clear",
|
||||
"Close": "-Close",
|
||||
|
|
Loading…
Reference in a new issue