Cef3 SendKeyEvent Special Chars (GLFW / OpenGL)

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Cef3 SendKeyEvent Special Chars (GLFW / OpenGL)

Postby azarus » Thu Oct 16, 2014 4:15 am

Hey,

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?
azarus
Newbie
 
Posts: 4
Joined: Mon Sep 01, 2014 10:31 pm

Re: Cef3 SendKeyEvent Special Chars (GLFW / OpenGL)

Postby magreenblatt » Thu Oct 16, 2014 8:32 am

azarus wrote:Do i have to convert each key one by one manually?

More or less. See either of the below examples, but of course it may be different depending on your toolkit and what CEF version you're using:

https://code.google.com/p/chromiumembed ... tk.cpp#979
https://code.google.com/p/javachromiume ... _N.cpp#510
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm

Re: Cef3 SendKeyEvent Special Chars (GLFW / OpenGL)

Postby azarus » Thu Oct 16, 2014 1:54 pm

Hey thanks for your response.

I followed these examples, i got the backspace and other special keys working by making a big switch.
But the ctrl+c ctrl-v and other key combinations are not working. And idea?

My guess is, there is no such thing and i have to define them my self. Am i right?

Thanks
azarus
Newbie
 
Posts: 4
Joined: Mon Sep 01, 2014 10:31 pm

Re: Cef3 SendKeyEvent Special Chars (GLFW / OpenGL)

Postby magreenblatt » Thu Oct 16, 2014 2:03 pm

azarus wrote:My guess is, there is no such thing and i have to define them my self. Am i right?

Handling of keyboard accelerators is generally framework- and platform-dependent.
magreenblatt
Site Admin
 
Posts: 12408
Joined: Fri May 29, 2009 6:57 pm


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 60 guests