1
0
mirror of https://github.com/salvadordf/CEF4Delphi.git synced 2024-11-24 08:02:15 +02:00

Fixed accented characters issue in web pages

This commit is contained in:
Salvador Díaz Fau 2020-04-23 12:32:52 +02:00
parent fd50565420
commit 22b59eae73
14 changed files with 178 additions and 131 deletions

View File

@ -75,13 +75,8 @@ type
implementation
uses
FMX.Forms,
uFMXExternalPumpBrowser,
uCEFFMXWorkScheduler,
{$IFDEF MSWINDOWS}
Winapi.Messages, Winapi.Windows,
{$ENDIF}
uCEFApplication, uCEFConstants;
FMX.Forms, {$IFDEF MSWINDOWS}Winapi.Messages, Winapi.Windows,{$ENDIF}
uFMXExternalPumpBrowser, uCEFFMXWorkScheduler, uCEFApplication, uCEFConstants;
class procedure TFMXApplicationService.AddPlatformService;
begin
@ -198,6 +193,18 @@ begin
(Application.MainForm is TFMXExternalPumpBrowserFrm) then
TFMXExternalPumpBrowserFrm(Application.MainForm).HandleSYSKEYUP(TempMsg);
WM_KEYDOWN :
if not(Application.Terminated) and
(Application.MainForm <> nil) and
(Application.MainForm is TFMXExternalPumpBrowserFrm) then
TFMXExternalPumpBrowserFrm(Application.MainForm).HandleKEYDOWN(TempMsg);
WM_KEYUP :
if not(Application.Terminated) and
(Application.MainForm <> nil) and
(Application.MainForm is TFMXExternalPumpBrowserFrm) then
TFMXExternalPumpBrowserFrm(Application.MainForm).HandleKEYUP(TempMsg);
WM_POINTERDOWN,
WM_POINTERUPDATE,
WM_POINTERUP :

View File

@ -101,7 +101,6 @@ object FMXExternalPumpBrowserFrm: TFMXExternalPumpBrowserFrm
OnMouseUp = Panel1MouseUp
OnMouseLeave = Panel1MouseLeave
OnMouseWheel = Panel1MouseWheel
OnKeyUp = Panel1KeyUp
OnKeyDown = Panel1KeyDown
end
object chrmosr: TFMXChromium

View File

@ -78,7 +78,6 @@ type
procedure Panel1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Single);
procedure Panel1MouseLeave(Sender: TObject);
procedure Panel1MouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; var Handled: Boolean);
procedure Panel1KeyUp(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState);
procedure Panel1KeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState);
procedure FormCreate(Sender: TObject);
@ -101,6 +100,7 @@ type
procedure Timer1Timer(Sender: TObject);
procedure AddressEdtEnter(Sender: TObject);
procedure SnapshotBtnClick(Sender: TObject);
procedure SnapshotBtnEnter(Sender: TObject);
@ -146,6 +146,8 @@ type
procedure HandleSYSCHAR(const aMessage : TMsg);
procedure HandleSYSKEYDOWN(const aMessage : TMsg);
procedure HandleSYSKEYUP(const aMessage : TMsg);
procedure HandleKEYDOWN(const aMessage : TMsg);
procedure HandleKEYUP(const aMessage : TMsg);
function HandlePOINTER(const aMessage : TMsg) : boolean;
{$ENDIF}
end;
@ -212,6 +214,8 @@ begin
GlobalCEFApp.MultiThreadedMessageLoop := False;
GlobalCEFApp.OnScheduleMessagePumpWork := GlobalCEFApp_OnScheduleMessagePumpWork;
//GlobalCEFApp.EnableGPU := True;
//GlobalCEFApp.LogFile := 'debug.log';
//GlobalCEFApp.LogSeverity := LOGSEVERITY_INFO;
end;
procedure TFMXExternalPumpBrowserFrm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
@ -332,32 +336,6 @@ var
begin
if not(Panel1.IsFocused) then exit;
if (Key <> 0) and (KeyChar = #0) then
begin
TempKeyEvent.kind := KEYEVENT_RAWKEYDOWN;
TempKeyEvent.modifiers := getModifiers(Shift);
TempKeyEvent.windows_key_code := Key;
TempKeyEvent.native_key_code := 0;
TempKeyEvent.is_system_key := ord(False);
TempKeyEvent.character := #0;
TempKeyEvent.unmodified_character := #0;
TempKeyEvent.focus_on_editable_field := ord(False);
chrmosr.SendKeyEvent(@TempKeyEvent);
if (Key in [VK_LEFT, VK_RIGHT, VK_UP, VK_DOWN, VK_TAB]) then Key := 0;
end;
end;
procedure TFMXExternalPumpBrowserFrm.Panel1KeyUp( Sender : TObject;
var Key : Word;
var KeyChar : Char;
Shift : TShiftState);
var
TempKeyEvent : TCefKeyEvent;
begin
if not(Panel1.IsFocused) then exit;
if (Key = 0) and (KeyChar <> #0) then
begin
TempKeyEvent.kind := KEYEVENT_CHAR;
@ -372,36 +350,9 @@ begin
chrmosr.SendKeyEvent(@TempKeyEvent);
end
else
if (Key <> 0) and (KeyChar = #0) then
begin
if (Key = VK_RETURN) then
begin
// FMX doesn't trigger this event with a KeyChar<>0
// to send a KEYEVENT_CHAR event for the VK_RETURN key.
// We add it manually before the KEYEVENT_KEYUP event.
TempKeyEvent.kind := KEYEVENT_CHAR;
TempKeyEvent.modifiers := getModifiers(Shift);
TempKeyEvent.windows_key_code := VK_RETURN;
TempKeyEvent.native_key_code := 0;
TempKeyEvent.is_system_key := ord(False);
TempKeyEvent.character := #0;
TempKeyEvent.unmodified_character := #0;
TempKeyEvent.focus_on_editable_field := ord(False);
chrmosr.SendKeyEvent(@TempKeyEvent);
end;
TempKeyEvent.kind := KEYEVENT_KEYUP;
TempKeyEvent.modifiers := getModifiers(Shift);
TempKeyEvent.windows_key_code := Key;
TempKeyEvent.native_key_code := 0;
TempKeyEvent.is_system_key := ord(False);
TempKeyEvent.character := #0;
TempKeyEvent.unmodified_character := #0;
TempKeyEvent.focus_on_editable_field := ord(False);
chrmosr.SendKeyEvent(@TempKeyEvent);
end;
if (Key <> 0) and (KeyChar = #0) and
(Key in [VK_LEFT, VK_RIGHT, VK_UP, VK_DOWN, VK_TAB]) then
Key := 0;
end;
procedure TFMXExternalPumpBrowserFrm.Panel1MouseDown(Sender : TObject;
@ -1002,6 +953,58 @@ begin
end;
end;
procedure TFMXExternalPumpBrowserFrm.HandleKEYDOWN(const aMessage : TMsg);
var
TempKeyEvent : TCefKeyEvent;
begin
if Panel1.IsFocused then
begin
TempKeyEvent.kind := KEYEVENT_RAWKEYDOWN;
TempKeyEvent.modifiers := GetCefKeyboardModifiers(aMessage.wParam, aMessage.lParam);
TempKeyEvent.windows_key_code := integer(aMessage.wParam);
TempKeyEvent.native_key_code := integer(aMessage.lParam);
TempKeyEvent.is_system_key := ord(False);
TempKeyEvent.character := #0;
TempKeyEvent.unmodified_character := #0;
TempKeyEvent.focus_on_editable_field := ord(False);
chrmosr.SendKeyEvent(@TempKeyEvent);
end;
end;
procedure TFMXExternalPumpBrowserFrm.HandleKEYUP(const aMessage : TMsg);
var
TempKeyEvent : TCefKeyEvent;
begin
if Panel1.IsFocused then
begin
if (aMessage.wParam = VK_RETURN) then
begin
TempKeyEvent.kind := KEYEVENT_CHAR;
TempKeyEvent.modifiers := GetCefKeyboardModifiers(aMessage.wParam, aMessage.lParam);
TempKeyEvent.windows_key_code := integer(aMessage.wParam);
TempKeyEvent.native_key_code := integer(aMessage.lParam);
TempKeyEvent.is_system_key := ord(False);
TempKeyEvent.character := #0;
TempKeyEvent.unmodified_character := #0;
TempKeyEvent.focus_on_editable_field := ord(False);
chrmosr.SendKeyEvent(@TempKeyEvent);
end;
TempKeyEvent.kind := KEYEVENT_KEYUP;
TempKeyEvent.modifiers := GetCefKeyboardModifiers(aMessage.wParam, aMessage.lParam);
TempKeyEvent.windows_key_code := integer(aMessage.wParam);
TempKeyEvent.native_key_code := integer(aMessage.lParam);
TempKeyEvent.is_system_key := ord(False);
TempKeyEvent.character := #0;
TempKeyEvent.unmodified_character := #0;
TempKeyEvent.focus_on_editable_field := ord(False);
chrmosr.SendKeyEvent(@TempKeyEvent);
end;
end;
function TFMXExternalPumpBrowserFrm.HandlePOINTER(const aMessage : TMsg) : boolean;
begin
Result := Panel1.IsFocused and

View File

@ -6,7 +6,7 @@
<MainSource>FMXTabbedBrowser.dpr</MainSource>
<Base>True</Base>
<Config Condition="'$(Config)'==''">Debug</Config>
<Platform Condition="'$(Platform)'==''">Win32</Platform>
<Platform Condition="'$(Platform)'==''">Win64</Platform>
<TargetedPlatforms>3</TargetedPlatforms>
<AppType>Application</AppType>
</PropertyGroup>

View File

@ -6,7 +6,7 @@
<MainSource>FMXTabbedOSRBrowser.dpr</MainSource>
<Base>True</Base>
<Config Condition="'$(Config)'==''">Debug</Config>
<Platform Condition="'$(Platform)'==''">Win64</Platform>
<Platform Condition="'$(Platform)'==''">Win32</Platform>
<TargetedPlatforms>3</TargetedPlatforms>
<AppType>Application</AppType>
</PropertyGroup>

View File

@ -125,7 +125,6 @@ object BrowserFrame: TBrowserFrame
OnMouseUp = FMXBufferPanel1MouseUp
OnMouseLeave = FMXBufferPanel1MouseLeave
OnMouseWheel = FMXBufferPanel1MouseWheel
OnKeyUp = FMXBufferPanel1KeyUp
OnKeyDown = FMXBufferPanel1KeyDown
end
object FMXChromium1: TFMXChromium

View File

@ -81,7 +81,6 @@ type
procedure FMXBufferPanel1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Single);
procedure FMXBufferPanel1MouseLeave(Sender: TObject);
procedure FMXBufferPanel1MouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; var Handled: Boolean);
procedure FMXBufferPanel1KeyUp(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState);
procedure FMXBufferPanel1KeyDown(Sender: TObject; var Key: Word; var KeyChar: Char; Shift: TShiftState);
procedure FMXChromium1AfterCreated(Sender: TObject; const browser: ICefBrowser);
@ -147,6 +146,8 @@ type
procedure HandleSYSCHAR(const aMessage : TMsg);
procedure HandleSYSKEYDOWN(const aMessage : TMsg);
procedure HandleSYSKEYUP(const aMessage : TMsg);
procedure HandleKEYDOWN(const aMessage : TMsg);
procedure HandleKEYUP(const aMessage : TMsg);
function HandlePOINTER(const aMessage : TMsg) : boolean;
{$ENDIF}
@ -281,30 +282,6 @@ var
begin
if not(FMXBufferPanel1.IsFocused) then exit;
if (Key <> 0) and (KeyChar = #0) then
begin
TempKeyEvent.kind := KEYEVENT_RAWKEYDOWN;
TempKeyEvent.modifiers := getModifiers(Shift);
TempKeyEvent.windows_key_code := Key;
TempKeyEvent.native_key_code := 0;
TempKeyEvent.is_system_key := ord(False);
TempKeyEvent.character := #0;
TempKeyEvent.unmodified_character := #0;
TempKeyEvent.focus_on_editable_field := ord(False);
FMXChromium1.SendKeyEvent(@TempKeyEvent);
if (Key in [VK_LEFT, VK_RIGHT, VK_UP, VK_DOWN, VK_TAB]) then Key := 0;
end;
end;
procedure TBrowserFrame.FMXBufferPanel1KeyUp(Sender: TObject; var Key: Word;
var KeyChar: Char; Shift: TShiftState);
var
TempKeyEvent : TCefKeyEvent;
begin
if not(FMXBufferPanel1.IsFocused) then exit;
if (Key = 0) and (KeyChar <> #0) then
begin
TempKeyEvent.kind := KEYEVENT_CHAR;
@ -319,36 +296,9 @@ begin
FMXChromium1.SendKeyEvent(@TempKeyEvent);
end
else
if (Key <> 0) and (KeyChar = #0) then
begin
if (Key = VK_RETURN) then
begin
// FMX doesn't trigger this event with a KeyChar<>0
// to send a KEYEVENT_CHAR event for the VK_RETURN key.
// We add it manually before the KEYEVENT_KEYUP event.
TempKeyEvent.kind := KEYEVENT_CHAR;
TempKeyEvent.modifiers := getModifiers(Shift);
TempKeyEvent.windows_key_code := VK_RETURN;
TempKeyEvent.native_key_code := 0;
TempKeyEvent.is_system_key := ord(False);
TempKeyEvent.character := #0;
TempKeyEvent.unmodified_character := #0;
TempKeyEvent.focus_on_editable_field := ord(False);
FMXChromium1.SendKeyEvent(@TempKeyEvent);
end;
TempKeyEvent.kind := KEYEVENT_KEYUP;
TempKeyEvent.modifiers := getModifiers(Shift);
TempKeyEvent.windows_key_code := Key;
TempKeyEvent.native_key_code := 0;
TempKeyEvent.is_system_key := ord(False);
TempKeyEvent.character := #0;
TempKeyEvent.unmodified_character := #0;
TempKeyEvent.focus_on_editable_field := ord(False);
FMXChromium1.SendKeyEvent(@TempKeyEvent);
end;
if (Key <> 0) and (KeyChar = #0) and
(Key in [VK_LEFT, VK_RIGHT, VK_UP, VK_DOWN, VK_TAB]) then
Key := 0;
end;
procedure TBrowserFrame.FMXBufferPanel1MouseDown(Sender: TObject;
@ -1094,6 +1044,58 @@ begin
end;
end;
procedure TBrowserFrame.HandleKEYDOWN(const aMessage : TMsg);
var
TempKeyEvent : TCefKeyEvent;
begin
if FMXBufferPanel1.IsFocused then
begin
TempKeyEvent.kind := KEYEVENT_RAWKEYDOWN;
TempKeyEvent.modifiers := GetCefKeyboardModifiers(aMessage.wParam, aMessage.lParam);
TempKeyEvent.windows_key_code := integer(aMessage.wParam);
TempKeyEvent.native_key_code := integer(aMessage.lParam);
TempKeyEvent.is_system_key := ord(False);
TempKeyEvent.character := #0;
TempKeyEvent.unmodified_character := #0;
TempKeyEvent.focus_on_editable_field := ord(False);
FMXChromium1.SendKeyEvent(@TempKeyEvent);
end;
end;
procedure TBrowserFrame.HandleKEYUP(const aMessage : TMsg);
var
TempKeyEvent : TCefKeyEvent;
begin
if FMXBufferPanel1.IsFocused then
begin
if (aMessage.wParam = VK_RETURN) then
begin
TempKeyEvent.kind := KEYEVENT_CHAR;
TempKeyEvent.modifiers := GetCefKeyboardModifiers(aMessage.wParam, aMessage.lParam);
TempKeyEvent.windows_key_code := integer(aMessage.wParam);
TempKeyEvent.native_key_code := integer(aMessage.lParam);
TempKeyEvent.is_system_key := ord(False);
TempKeyEvent.character := #0;
TempKeyEvent.unmodified_character := #0;
TempKeyEvent.focus_on_editable_field := ord(False);
FMXChromium1.SendKeyEvent(@TempKeyEvent);
end;
TempKeyEvent.kind := KEYEVENT_KEYUP;
TempKeyEvent.modifiers := GetCefKeyboardModifiers(aMessage.wParam, aMessage.lParam);
TempKeyEvent.windows_key_code := integer(aMessage.wParam);
TempKeyEvent.native_key_code := integer(aMessage.lParam);
TempKeyEvent.is_system_key := ord(False);
TempKeyEvent.character := #0;
TempKeyEvent.unmodified_character := #0;
TempKeyEvent.focus_on_editable_field := ord(False);
FMXChromium1.SendKeyEvent(@TempKeyEvent);
end;
end;
function TBrowserFrame.HandlePOINTER(const aMessage : TMsg) : boolean;
begin
Result := FMXBufferPanel1.IsFocused and

View File

@ -70,6 +70,8 @@ type
procedure HandleSYSCHAR(const aMessage : TMsg);
procedure HandleSYSKEYDOWN(const aMessage : TMsg);
procedure HandleSYSKEYUP(const aMessage : TMsg);
procedure HandleKEYDOWN(const aMessage : TMsg);
procedure HandleKEYUP(const aMessage : TMsg);
function HandlePOINTER(const aMessage : TMsg) : boolean;
function PostFormMessage(aMsg : cardinal; aWParam : WPARAM = 0; aLParam : LPARAM = 0) : boolean;
{$ENDIF}
@ -189,6 +191,18 @@ begin
FBrowserFrame.HandleSYSKEYUP(aMessage);
end;
procedure TBrowserTab.HandleKEYDOWN(const aMessage : TMsg);
begin
if (FBrowserFrame <> nil) then
FBrowserFrame.HandleKEYDOWN(aMessage);
end;
procedure TBrowserTab.HandleKEYUP(const aMessage : TMsg);
begin
if (FBrowserFrame <> nil) then
FBrowserFrame.HandleKEYUP(aMessage);
end;
function TBrowserTab.HandlePOINTER(const aMessage : TMsg) : boolean;
begin
Result := (FBrowserFrame <> nil) and

View File

@ -75,11 +75,8 @@ type
implementation
uses
FMX.Forms,
uMainForm,
uCEFFMXWorkScheduler,
Winapi.Messages, Winapi.Windows,
uCEFApplication, uCEFConstants;
FMX.Forms, {$IFDEF MSWINDOWS}Winapi.Messages, Winapi.Windows,{$ENDIF}
uMainForm, uCEFFMXWorkScheduler, uCEFApplication, uCEFConstants;
class procedure TFMXApplicationService.AddPlatformService;
begin
@ -196,6 +193,18 @@ begin
(Application.MainForm is TMainForm) then
TMainForm(Application.MainForm).HandleSYSKEYUP(TempMsg);
WM_KEYDOWN :
if not(Application.Terminated) and
(Application.MainForm <> nil) and
(Application.MainForm is TMainForm) then
TMainForm(Application.MainForm).HandleKEYDOWN(TempMsg);
WM_KEYUP :
if not(Application.Terminated) and
(Application.MainForm <> nil) and
(Application.MainForm is TMainForm) then
TMainForm(Application.MainForm).HandleKEYUP(TempMsg);
WM_POINTERDOWN,
WM_POINTERUPDATE,
WM_POINTERUP :

View File

@ -104,6 +104,8 @@ type
procedure HandleSYSCHAR(const aMessage : TMsg);
procedure HandleSYSKEYDOWN(const aMessage : TMsg);
procedure HandleSYSKEYUP(const aMessage : TMsg);
procedure HandleKEYDOWN(const aMessage : TMsg);
procedure HandleKEYUP(const aMessage : TMsg);
function HandlePOINTER(const aMessage : TMsg) : boolean;
function PostCustomMessage(aMsg : cardinal; aWParam : WPARAM = 0; aLParam : LPARAM = 0) : boolean;
{$ENDIF}
@ -423,6 +425,18 @@ begin
TBrowserTab(BrowserTabCtrl.ActiveTab).HandleSYSKEYUP(aMessage);
end;
procedure TMainForm.HandleKEYDOWN(const aMessage : TMsg);
begin
if (BrowserTabCtrl.ActiveTab <> nil) then
TBrowserTab(BrowserTabCtrl.ActiveTab).HandleKEYDOWN(aMessage);
end;
procedure TMainForm.HandleKEYUP(const aMessage : TMsg);
begin
if (BrowserTabCtrl.ActiveTab <> nil) then
TBrowserTab(BrowserTabCtrl.ActiveTab).HandleKEYUP(aMessage);
end;
function TMainForm.HandlePOINTER(const aMessage : TMsg) : boolean;
begin
Result := (BrowserTabCtrl.ActiveTab <> nil) and

View File

@ -6,7 +6,7 @@
<MainSource>FMXToolBoxBrowser.dpr</MainSource>
<Base>True</Base>
<Config Condition="'$(Config)'==''">Debug</Config>
<Platform Condition="'$(Platform)'==''">Win32</Platform>
<Platform Condition="'$(Platform)'==''">Win64</Platform>
<TargetedPlatforms>3</TargetedPlatforms>
<AppType>Application</AppType>
</PropertyGroup>

View File

@ -6,7 +6,7 @@
<MainSource>SimpleFMXBrowser.dpr</MainSource>
<Base>True</Base>
<Config Condition="'$(Config)'==''">Debug</Config>
<Platform Condition="'$(Platform)'==''">Win32</Platform>
<Platform Condition="'$(Platform)'==''">Win64</Platform>
<TargetedPlatforms>3</TargetedPlatforms>
<AppType>Application</AppType>
</PropertyGroup>

Binary file not shown.

View File

@ -2,7 +2,7 @@
"UpdateLazPackages" : [
{
"ForceNotify" : true,
"InternalVersion" : 123,
"InternalVersion" : 124,
"Name" : "cef4delphi_lazarus.lpk",
"Version" : "81.2.22.0"
}