I am trying to implement Cef3 in a Glfw / OpenGL application.
I have this code for text handling that works fine but only with text input. Backspace ctrl+a ctrl+c ctrl+z etc... special characters are not working.
- Code: Select all
glfwSetKeyCallback(pWindow, KeyCallback);
glfwSetCharCallback(pWindow, TextCallback);
- Code: Select all
void TextCallback(GLFWwindow *window, unsigned int keycode)
{
CefKeyEvent key;
key.type = KEYEVENT_CHAR;
key.modifiers = 0;
key.windows_key_code = keycode;
pBrowser->GetHost()->SendKeyEvent(key);
}
This code is not working i am just trying to figure out how to send key events correctly:
- Code: Select all
void KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
CefKeyEvent keyEvent;
keyEvent.windows_key_code = keyCode; // I should convert the keys to VK_ keys?
if(action == 1)
{
keyEvent.type = KEYEVENT_KEYDOWN;
}else{
keyEvent.type = KEYEVENT_KEYUP;
}
pBrowser->GetHost()->SendKeyEvent(keyEvent);
}
Do i have to convert each key one by one manually? Or is there any better alternative?