mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 09:27:00 +00:00
Adding an ImGuiKey 'ImGuiKey_EnterSecondary' to support platforms that differentiate the enter (return key) and the numpad enter key.
This commit is contained in:
parent
4b44f25c9a
commit
0f86116a69
@ -281,6 +281,7 @@ bool ImGui_ImplAllegro5_Init(ALLEGRO_DISPLAY* display)
|
|||||||
io.KeyMap[ImGuiKey_Backspace] = ALLEGRO_KEY_BACKSPACE;
|
io.KeyMap[ImGuiKey_Backspace] = ALLEGRO_KEY_BACKSPACE;
|
||||||
io.KeyMap[ImGuiKey_Space] = ALLEGRO_KEY_SPACE;
|
io.KeyMap[ImGuiKey_Space] = ALLEGRO_KEY_SPACE;
|
||||||
io.KeyMap[ImGuiKey_Enter] = ALLEGRO_KEY_ENTER;
|
io.KeyMap[ImGuiKey_Enter] = ALLEGRO_KEY_ENTER;
|
||||||
|
io.KeyMap[ImGuiKey_EnterSecondary] = ALLEGRO_KEY_PAD_ENTER;
|
||||||
io.KeyMap[ImGuiKey_Escape] = ALLEGRO_KEY_ESCAPE;
|
io.KeyMap[ImGuiKey_Escape] = ALLEGRO_KEY_ESCAPE;
|
||||||
io.KeyMap[ImGuiKey_A] = ALLEGRO_KEY_A;
|
io.KeyMap[ImGuiKey_A] = ALLEGRO_KEY_A;
|
||||||
io.KeyMap[ImGuiKey_C] = ALLEGRO_KEY_C;
|
io.KeyMap[ImGuiKey_C] = ALLEGRO_KEY_C;
|
||||||
|
@ -150,6 +150,7 @@ static bool ImGui_ImplGlfw_Init(GLFWwindow* window, bool install_callbacks, Glfw
|
|||||||
io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
|
io.KeyMap[ImGuiKey_Backspace] = GLFW_KEY_BACKSPACE;
|
||||||
io.KeyMap[ImGuiKey_Space] = GLFW_KEY_SPACE;
|
io.KeyMap[ImGuiKey_Space] = GLFW_KEY_SPACE;
|
||||||
io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
|
io.KeyMap[ImGuiKey_Enter] = GLFW_KEY_ENTER;
|
||||||
|
io.KeyMap[ImGuiKey_EnterSecondary] = GLFW_KEY_KP_ENTER;
|
||||||
io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
|
io.KeyMap[ImGuiKey_Escape] = GLFW_KEY_ESCAPE;
|
||||||
io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
|
io.KeyMap[ImGuiKey_A] = GLFW_KEY_A;
|
||||||
io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
|
io.KeyMap[ImGuiKey_C] = GLFW_KEY_C;
|
||||||
|
@ -234,6 +234,7 @@ bool ImGui_Marmalade_Init(bool install_callbacks)
|
|||||||
io.KeyMap[ImGuiKey_Backspace] = s3eKeyBackspace;
|
io.KeyMap[ImGuiKey_Backspace] = s3eKeyBackspace;
|
||||||
io.KeyMap[ImGuiKey_Space] = s3eKeySpace;
|
io.KeyMap[ImGuiKey_Space] = s3eKeySpace;
|
||||||
io.KeyMap[ImGuiKey_Enter] = s3eKeyEnter;
|
io.KeyMap[ImGuiKey_Enter] = s3eKeyEnter;
|
||||||
|
io.KeyMap[ImGuiKey_EnterSecondary] = s3eKeyNumPadEnter;
|
||||||
io.KeyMap[ImGuiKey_Escape] = s3eKeyEsc;
|
io.KeyMap[ImGuiKey_Escape] = s3eKeyEsc;
|
||||||
io.KeyMap[ImGuiKey_A] = s3eKeyA;
|
io.KeyMap[ImGuiKey_A] = s3eKeyA;
|
||||||
io.KeyMap[ImGuiKey_C] = s3eKeyC;
|
io.KeyMap[ImGuiKey_C] = s3eKeyC;
|
||||||
|
@ -47,27 +47,28 @@ bool ImGui_ImplOSX_Init()
|
|||||||
|
|
||||||
// Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
|
// Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array.
|
||||||
const int offset_for_function_keys = 256 - 0xF700;
|
const int offset_for_function_keys = 256 - 0xF700;
|
||||||
io.KeyMap[ImGuiKey_Tab] = '\t';
|
io.KeyMap[ImGuiKey_Tab] = '\t';
|
||||||
io.KeyMap[ImGuiKey_LeftArrow] = NSLeftArrowFunctionKey + offset_for_function_keys;
|
io.KeyMap[ImGuiKey_LeftArrow] = NSLeftArrowFunctionKey + offset_for_function_keys;
|
||||||
io.KeyMap[ImGuiKey_RightArrow] = NSRightArrowFunctionKey + offset_for_function_keys;
|
io.KeyMap[ImGuiKey_RightArrow] = NSRightArrowFunctionKey + offset_for_function_keys;
|
||||||
io.KeyMap[ImGuiKey_UpArrow] = NSUpArrowFunctionKey + offset_for_function_keys;
|
io.KeyMap[ImGuiKey_UpArrow] = NSUpArrowFunctionKey + offset_for_function_keys;
|
||||||
io.KeyMap[ImGuiKey_DownArrow] = NSDownArrowFunctionKey + offset_for_function_keys;
|
io.KeyMap[ImGuiKey_DownArrow] = NSDownArrowFunctionKey + offset_for_function_keys;
|
||||||
io.KeyMap[ImGuiKey_PageUp] = NSPageUpFunctionKey + offset_for_function_keys;
|
io.KeyMap[ImGuiKey_PageUp] = NSPageUpFunctionKey + offset_for_function_keys;
|
||||||
io.KeyMap[ImGuiKey_PageDown] = NSPageDownFunctionKey + offset_for_function_keys;
|
io.KeyMap[ImGuiKey_PageDown] = NSPageDownFunctionKey + offset_for_function_keys;
|
||||||
io.KeyMap[ImGuiKey_Home] = NSHomeFunctionKey + offset_for_function_keys;
|
io.KeyMap[ImGuiKey_Home] = NSHomeFunctionKey + offset_for_function_keys;
|
||||||
io.KeyMap[ImGuiKey_End] = NSEndFunctionKey + offset_for_function_keys;
|
io.KeyMap[ImGuiKey_End] = NSEndFunctionKey + offset_for_function_keys;
|
||||||
io.KeyMap[ImGuiKey_Insert] = NSInsertFunctionKey + offset_for_function_keys;
|
io.KeyMap[ImGuiKey_Insert] = NSInsertFunctionKey + offset_for_function_keys;
|
||||||
io.KeyMap[ImGuiKey_Delete] = NSDeleteFunctionKey + offset_for_function_keys;
|
io.KeyMap[ImGuiKey_Delete] = NSDeleteFunctionKey + offset_for_function_keys;
|
||||||
io.KeyMap[ImGuiKey_Backspace] = 127;
|
io.KeyMap[ImGuiKey_Backspace] = 127;
|
||||||
io.KeyMap[ImGuiKey_Space] = 32;
|
io.KeyMap[ImGuiKey_Space] = 32;
|
||||||
io.KeyMap[ImGuiKey_Enter] = 13;
|
io.KeyMap[ImGuiKey_Enter] = 13;
|
||||||
io.KeyMap[ImGuiKey_Escape] = 27;
|
io.KeyMap[ImGuiKey_EnterSecondary] = 13;
|
||||||
io.KeyMap[ImGuiKey_A] = 'A';
|
io.KeyMap[ImGuiKey_Escape] = 27;
|
||||||
io.KeyMap[ImGuiKey_C] = 'C';
|
io.KeyMap[ImGuiKey_A] = 'A';
|
||||||
io.KeyMap[ImGuiKey_V] = 'V';
|
io.KeyMap[ImGuiKey_C] = 'C';
|
||||||
io.KeyMap[ImGuiKey_X] = 'X';
|
io.KeyMap[ImGuiKey_V] = 'V';
|
||||||
io.KeyMap[ImGuiKey_Y] = 'Y';
|
io.KeyMap[ImGuiKey_X] = 'X';
|
||||||
io.KeyMap[ImGuiKey_Z] = 'Z';
|
io.KeyMap[ImGuiKey_Y] = 'Y';
|
||||||
|
io.KeyMap[ImGuiKey_Z] = 'Z';
|
||||||
|
|
||||||
// Load cursors. Some of them are undocumented.
|
// Load cursors. Some of them are undocumented.
|
||||||
g_MouseCursorHidden = false;
|
g_MouseCursorHidden = false;
|
||||||
|
@ -143,6 +143,7 @@ static bool ImGui_ImplSDL2_Init(SDL_Window* window)
|
|||||||
io.KeyMap[ImGuiKey_Backspace] = SDL_SCANCODE_BACKSPACE;
|
io.KeyMap[ImGuiKey_Backspace] = SDL_SCANCODE_BACKSPACE;
|
||||||
io.KeyMap[ImGuiKey_Space] = SDL_SCANCODE_SPACE;
|
io.KeyMap[ImGuiKey_Space] = SDL_SCANCODE_SPACE;
|
||||||
io.KeyMap[ImGuiKey_Enter] = SDL_SCANCODE_RETURN;
|
io.KeyMap[ImGuiKey_Enter] = SDL_SCANCODE_RETURN;
|
||||||
|
io.KeyMap[ImGuiKey_EnterSecondary] = SDL_SCANCODE_RETURN2;
|
||||||
io.KeyMap[ImGuiKey_Escape] = SDL_SCANCODE_ESCAPE;
|
io.KeyMap[ImGuiKey_Escape] = SDL_SCANCODE_ESCAPE;
|
||||||
io.KeyMap[ImGuiKey_A] = SDL_SCANCODE_A;
|
io.KeyMap[ImGuiKey_A] = SDL_SCANCODE_A;
|
||||||
io.KeyMap[ImGuiKey_C] = SDL_SCANCODE_C;
|
io.KeyMap[ImGuiKey_C] = SDL_SCANCODE_C;
|
||||||
|
@ -77,6 +77,7 @@ bool ImGui_ImplWin32_Init(void* hwnd)
|
|||||||
io.KeyMap[ImGuiKey_Backspace] = VK_BACK;
|
io.KeyMap[ImGuiKey_Backspace] = VK_BACK;
|
||||||
io.KeyMap[ImGuiKey_Space] = VK_SPACE;
|
io.KeyMap[ImGuiKey_Space] = VK_SPACE;
|
||||||
io.KeyMap[ImGuiKey_Enter] = VK_RETURN;
|
io.KeyMap[ImGuiKey_Enter] = VK_RETURN;
|
||||||
|
io.KeyMap[ImGuiKey_EnterSecondary] = VK_RETURN;
|
||||||
io.KeyMap[ImGuiKey_Escape] = VK_ESCAPE;
|
io.KeyMap[ImGuiKey_Escape] = VK_ESCAPE;
|
||||||
io.KeyMap[ImGuiKey_A] = 'A';
|
io.KeyMap[ImGuiKey_A] = 'A';
|
||||||
io.KeyMap[ImGuiKey_C] = 'C';
|
io.KeyMap[ImGuiKey_C] = 'C';
|
||||||
|
1
imgui.h
1
imgui.h
@ -940,6 +940,7 @@ enum ImGuiKey_
|
|||||||
ImGuiKey_Backspace,
|
ImGuiKey_Backspace,
|
||||||
ImGuiKey_Space,
|
ImGuiKey_Space,
|
||||||
ImGuiKey_Enter,
|
ImGuiKey_Enter,
|
||||||
|
ImGuiKey_EnterSecondary,
|
||||||
ImGuiKey_Escape,
|
ImGuiKey_Escape,
|
||||||
ImGuiKey_A, // for text edit CTRL+A: select all
|
ImGuiKey_A, // for text edit CTRL+A: select all
|
||||||
ImGuiKey_C, // for text edit CTRL+C: copy
|
ImGuiKey_C, // for text edit CTRL+C: copy
|
||||||
|
@ -3653,7 +3653,7 @@ bool ImGui::InputTextEx(const char* label, const char* hint, char* buf, int buf_
|
|||||||
}
|
}
|
||||||
state->OnKeyPressed(STB_TEXTEDIT_K_BACKSPACE | k_mask);
|
state->OnKeyPressed(STB_TEXTEDIT_K_BACKSPACE | k_mask);
|
||||||
}
|
}
|
||||||
else if (IsKeyPressedMap(ImGuiKey_Enter))
|
else if (IsKeyPressedMap(ImGuiKey_Enter) || IsKeyPressedMap(ImGuiKey_EnterSecondary))
|
||||||
{
|
{
|
||||||
bool ctrl_enter_for_new_line = (flags & ImGuiInputTextFlags_CtrlEnterForNewLine) != 0;
|
bool ctrl_enter_for_new_line = (flags & ImGuiInputTextFlags_CtrlEnterForNewLine) != 0;
|
||||||
if (!is_multiline || (ctrl_enter_for_new_line && !io.KeyCtrl) || (!ctrl_enter_for_new_line && io.KeyCtrl))
|
if (!is_multiline || (ctrl_enter_for_new_line && !io.KeyCtrl) || (!ctrl_enter_for_new_line && io.KeyCtrl))
|
||||||
|
Loading…
Reference in New Issue
Block a user