C++ 铬嵌入式框架绑定按键

C++ 铬嵌入式框架绑定按键,c++,bind,keypress,chromium-embedded,C++,Bind,Keypress,Chromium Embedded,我在Chromium Embedded Framework的官方论坛上看到了这一点,但似乎没有给出解决方案。老实说,我不太喜欢C++平台。你能帮我提供一个将CEF绑定到webapp的代码片段吗 我想使用默认控件控制应用程序: ALT+F4-关闭 F5-刷新浏览器短版本:实现CefKeyboardHandler,特别是OnPreKeyEvent() JS和C++之间的通信是通过V8扩展完成的,或者是通过将函数绑定到CEFFixor来完成的。详情请浏览 这带来了一些陷阱——您的事件捕获器“只是另一

我在Chromium Embedded Framework的官方论坛上看到了这一点,但似乎没有给出解决方案。老实说,我不太喜欢C++平台。你能帮我提供一个将CEF绑定到webapp的代码片段吗

我想使用默认控件控制应用程序:

ALT+F4-关闭

F5-刷新浏览器

短版本:实现
CefKeyboardHandler
,特别是
OnPreKeyEvent()

<> JS和C++之间的通信是通过V8扩展完成的,或者是通过将函数绑定到CEFFixor来完成的。详情请浏览

这带来了一些陷阱——您的事件捕获器“只是另一个Javascript事件处理程序”,并且随之而来的是调用它的时间(在其他事件处理程序之前或之后)等所有不确定性。谢天谢地,CEF有一个漂亮的小
CefKeyboardHandler
,只为做你想做的事

使用键盘处理程序截取按键 参见
cef\u keyboard\u handler.h
-OnPreKeyEvent()的文档说明:

// Called before a keyboard event is sent to the renderer. |event| contains
// information about the keyboard event. |os_event| is the operating system
// event message, if any. Return true if the event was handled or false
// otherwise. If the event will be handled in OnKeyEvent() as a keyboard
// shortcut set |is_keyboard_shortcut| to true and return false.
从这里开始,这很简单。
cefenthandle
解析为特定于平台的标准Windows
MSG
。请注意,Alt+F4是一个特殊的系统命令:

当您按下某个键时,具有键盘焦点的窗口将接收一个 以下消息的一部分

WM_SYSKEYDOWN(或)WM_KEYDOWN

WM_SYSKEYDOWN消息表示一个系统键,它是调用 系统命令。有两种类型的系统键:ALT+任意键和F10


你在寻找C++代码,它将捕获关键事件并发送到CEF吗?我相信这在CEFClient中是默认情况下发生的(假设您正在构建它)——毕竟您可以在CEF文本框中键入内容……添加了答案——呸,这需要时间!能否在OnPreKeyEvent()中获取鼠标状态?
$(document).keypress(function (e) {
  ...
  NativeAppFunction();
  //Or NativeAppExtension.Function();
}
// Called before a keyboard event is sent to the renderer. |event| contains
// information about the keyboard event. |os_event| is the operating system
// event message, if any. Return true if the event was handled or false
// otherwise. If the event will be handled in OnKeyEvent() as a keyboard
// shortcut set |is_keyboard_shortcut| to true and return false.