1
0
mirror of synced 2025-02-20 04:01:01 +01:00

ux: Properly use current key layout for shortcuts

This commit is contained in:
WerWolv 2021-03-26 21:40:35 +01:00
parent 2c3a6d38ab
commit 42461c467f
3 changed files with 13 additions and 8 deletions

View File

@ -68,7 +68,7 @@ namespace hex {
}
bool ViewCommandPalette::handleShortcut(int key, int mods) {
if (key == GLFW_KEY_P && mods == (GLFW_MOD_SHIFT | GLFW_MOD_CONTROL)) {
if (key == 'P' && mods == (GLFW_MOD_SHIFT | GLFW_MOD_CONTROL)) {
View::doLater([this] {
ImGui::OpenPopup("hex.view.command_palette.name"_lang);
this->m_commandPaletteOpen = true;

View File

@ -501,25 +501,25 @@ namespace hex {
}
bool ViewHexEditor::handleShortcut(int key, int mods) {
if (mods == GLFW_MOD_CONTROL && key == GLFW_KEY_S) {
if (mods == GLFW_MOD_CONTROL && key == 'S') {
save();
return true;
} else if (mods == (GLFW_MOD_CONTROL | GLFW_MOD_SHIFT) && key == GLFW_KEY_S) {
} else if (mods == (GLFW_MOD_CONTROL | GLFW_MOD_SHIFT) && key == 'S') {
saveAs();
return true;
} else if (mods == GLFW_MOD_CONTROL && key == GLFW_KEY_F) {
} else if (mods == GLFW_MOD_CONTROL && key == 'Z') {
View::doLater([]{ ImGui::OpenPopup("hex.view.hexeditor.menu.file.search"_lang); });
return true;
} else if (mods == GLFW_MOD_CONTROL && key == GLFW_KEY_G) {
} else if (mods == GLFW_MOD_CONTROL && key == 'G') {
View::doLater([]{ ImGui::OpenPopup("hex.view.hexeditor.menu.file.goto"_lang); });
return true;
} else if (mods == GLFW_MOD_CONTROL && key == GLFW_KEY_O) {
} else if (mods == GLFW_MOD_CONTROL && key == 'O') {
View::doLater([]{ ImGui::OpenPopup("hex.view.hexeditor.open_file"_lang); });
return true;
} else if (mods == (GLFW_MOD_CONTROL | GLFW_MOD_ALT) && key == GLFW_KEY_C) {
} else if (mods == (GLFW_MOD_CONTROL | GLFW_MOD_ALT) && key == 'C') {
this->copyBytes();
return true;
} else if (mods == (GLFW_MOD_CONTROL | GLFW_MOD_SHIFT) && key == GLFW_KEY_C) {
} else if (mods == (GLFW_MOD_CONTROL | GLFW_MOD_SHIFT) && key == 'C') {
this->copyString();
return true;
}

View File

@ -612,6 +612,11 @@ namespace hex {
});
glfwSetKeyCallback(this->m_window, [](GLFWwindow *window, int key, int scancode, int action, int mods) {
auto keyName = glfwGetKeyName(key, scancode);
if (keyName != nullptr)
key = std::toupper(keyName[0]);
if (action == GLFW_PRESS) {
Window::s_currShortcut = { key, mods };
auto &io = ImGui::GetIO();