版本说明,用于版本CEF4_87.0.4280.141,cef_binary_87.1.14。为什么要用这个版本,因为这是最后一个支持flash的版本。

主要功能

1、支持非OSR模式下中文输入。

2、支持输入框和富文本框输入。

3、输入法选择框跟随输入光标移动。

4、支持H5元素拖动。

ScreenShot_2026-01-21_232521_138

ScreenShot_2026-01-21_232659_403

 

使用说明

一、下载libcefcninput.so放在与应用程序和CEFbinary同一目录下。先确保您的CEF浏览器运行正常,进行后台操作。
二、在CEF显示页面加上
1、在全局里加
uses
Gtk2Globals;

type
TintInputDll=procedure (InChromium: TChromium;InCEFShow:TWinControl;In_im_context: PGtkIMContext;In_isDebug:Boolean); stdcall;
ToutInputDll= procedure; stdcall;
TSetInputWait=procedure (WaitMs:int64); stdcall;
TGetInputWait=function:Int64; stdcall;
var
intInputDll:TintInputDll;
outInputDll:ToutInputDll;
SetInputWait:TSetInputWait;
GetInputWait:TGetInputWait;
HndDLL: THandle;
2、在FormCreate事件中加
var
IntAddr,OutAddr,GetWaitAddr,SetWaitAddr: Pointer;

//加载动态库
HndDLL := LoadLibrary('./libcefcninput.so');
IntAddr:=GetProcAddress(HndDLL, 'intInputDll');
OutAddr:=GetProcAddress(HndDLL, 'outInputDll');
GetWaitAddr:=GetProcAddress(HndDLL,'GetInputWait');
SetWaitAddr:=GetProcAddress(HndDLL,'SetInputWait');
if Assigned(IntAddr) and Assigned(OutAddr) then
begin
intInputDll:=TintInputDll(IntAddr);
outInputDll:=ToutInputDll(OutAddr);
GetInputWait:=TGetInputWait(GetWaitAddr);
SetInputWait:=TSetInputWait(SetWaitAddr);
intInputDll(Chromium1,CEFLinkedWindowParent1,im_context,false); //初始化中文输入法组件
end
else
ShowMessage('加载中文输入组件出错,不能输入中文。');
3、在FormCloseQuery事件中加
if HndDLL<>-1 then
begin
outInputDll;
UnloadLibrary(HndDLL);
HndDLL:=-1;
end;
三、函数说明
1、初始化中文输入法
procedure intInputDll(InChromium: TChromium;InCEFShow:TWinControl;In_im_context: PGtkIMContext;In_isDebug:Boolean);
In_isDebug是否输出坐标等信息
2、退出中文输入法
procedure outInputDll;
3、设置输入等待时间
主要用于部分输入法在英文状态时不会由输入法输出英文字符,等待判断是否是输入英文。
系统初始化时会根据计算机运行速度设置一个初始值。
如果出现中文状态时首字母输入到浏览器时才要手动设置。X86系统设置为10以上比较安全;arm和arm64最小20,50比较安全
procedure SetInputWait(WaitMs:int64);
4、得到当前输入等待时间
function GetInputWait():Int64;

 

通过网盘分享的文件:Cef中文输入组件
链接: https://pan.baidu.com/s/12bUcaPgp8chahGkmBnxOmw?pwd=cefc 提取码: cefc

posted on 2026-01-21 23:32  禁卫军  阅读(0)  评论(0)    收藏  举报