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

Added TBufferPanel.OnUTF8KeyPress event for Lazarus

- Bug fix #120
This commit is contained in:
Salvador Díaz Fau 2018-06-18 21:57:18 +02:00
parent 09161b19e1
commit f05fbdc8ce
4 changed files with 108 additions and 95 deletions

View File

@ -4,14 +4,13 @@
<PathDelim Value="\"/>
<Version Value="10"/>
<BuildModes Active="Default"/>
<Units Count="15">
<Units Count="18">
<Unit0>
<Filename Value="SimpleLazOSRBrowser.lpr"/>
<IsPartOfProject Value="True"/>
<IsVisibleTab Value="True"/>
<TopLine Value="31"/>
<CursorPos X="10" Y="43"/>
<UsageCount Value="39"/>
<UsageCount Value="40"/>
<Loaded Value="True"/>
<DefaultSyntaxHighlighter Value="Delphi"/>
</Unit0>
@ -21,13 +20,14 @@
<ComponentName Value="Form1"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
<EditorIndex Value="1"/>
<TopLine Value="781"/>
<CursorPos Y="788"/>
<UsageCount Value="39"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="2"/>
<TopLine Value="186"/>
<CursorPos X="15" Y="191"/>
<UsageCount Value="40"/>
<Bookmarks Count="2">
<Item0 Y="558" ID="2"/>
<Item1 X="43" Y="797" ID="1"/>
<Item0 Y="189" ID="1"/>
<Item1 X="5" Y="805" ID="2"/>
</Bookmarks>
<Loaded Value="True"/>
<LoadedDesigner Value="True"/>
@ -45,10 +45,11 @@
</Unit2>
<Unit3>
<Filename Value="..\..\source\uBufferPanel.pas"/>
<EditorIndex Value="-1"/>
<TopLine Value="138"/>
<CursorPos X="28" Y="163"/>
<UsageCount Value="16"/>
<EditorIndex Value="1"/>
<TopLine Value="95"/>
<CursorPos X="41" Y="126"/>
<UsageCount Value="17"/>
<Loaded Value="True"/>
</Unit3>
<Unit4>
<Filename Value="..\..\..\..\lcl\lcltype.pp"/>
@ -85,17 +86,16 @@
<Filename Value="C:\lazarus\lcl\controls.pp"/>
<UnitName Value="Controls"/>
<EditorIndex Value="-1"/>
<TopLine Value="2054"/>
<CursorPos X="82" Y="2074"/>
<TopLine Value="1917"/>
<CursorPos X="14" Y="2195"/>
<UsageCount Value="11"/>
</Unit8>
<Unit9>
<Filename Value="C:\lazarus\lcl\include\wincontrol.inc"/>
<EditorIndex Value="4"/>
<EditorIndex Value="-1"/>
<TopLine Value="5880"/>
<CursorPos Y="5898"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit9>
<Unit10>
<Filename Value="C:\lazarus\lcl\widgetset\wscontrols.pp"/>
@ -107,11 +107,10 @@
</Unit10>
<Unit11>
<Filename Value="..\..\source\uCEFMiscFunctions.pas"/>
<EditorIndex Value="2"/>
<TopLine Value="1508"/>
<CursorPos X="23" Y="1519"/>
<EditorIndex Value="-1"/>
<TopLine Value="1505"/>
<CursorPos X="51" Y="1534"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit11>
<Unit12>
<Filename Value="..\..\source\uCEFConstants.pas"/>
@ -129,134 +128,140 @@
</Unit13>
<Unit14>
<Filename Value="C:\lazarus\fpc\3.0.4\source\rtl\win\wininc\defines.inc"/>
<EditorIndex Value="3"/>
<EditorIndex Value="-1"/>
<TopLine Value="4867"/>
<CursorPos X="6" Y="4753"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit14>
<Unit15>
<Filename Value="C:\lazarus\lcl\extctrls.pp"/>
<UnitName Value="ExtCtrls"/>
<EditorIndex Value="-1"/>
<TopLine Value="995"/>
<CursorPos X="39" Y="1017"/>
<UsageCount Value="10"/>
</Unit15>
<Unit16>
<Filename Value="C:\lazarus\fpc\3.0.4\source\rtl\inc\ustringh.inc"/>
<EditorIndex Value="-1"/>
<TopLine Value="117"/>
<CursorPos X="67" Y="141"/>
<UsageCount Value="10"/>
</Unit16>
<Unit17>
<Filename Value="C:\lazarus\fpc\3.0.4\source\rtl\win64\system.pp"/>
<UnitName Value="System"/>
<EditorIndex Value="-1"/>
<TopLine Value="551"/>
<CursorPos X="15" Y="580"/>
<UsageCount Value="10"/>
</Unit17>
</Units>
<JumpHistory Count="30" HistoryIndex="29">
<JumpHistory Count="26" HistoryIndex="25">
<Position1>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="858" Column="69" TopLine="844"/>
<Filename Value="..\..\source\uBufferPanel.pas"/>
<Caret Line="163" Column="28" TopLine="43"/>
</Position1>
<Position2>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="889" TopLine="862"/>
<Caret Line="800" Column="81" TopLine="787"/>
</Position2>
<Position3>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="85" Column="87" TopLine="67"/>
<Caret Line="191" Column="3" TopLine="180"/>
</Position3>
<Position4>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="90" Column="36" TopLine="67"/>
<Caret Line="78" Column="25" TopLine="73"/>
</Position4>
<Position5>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="248" Column="39" TopLine="218"/>
<Caret Line="789" TopLine="788"/>
</Position5>
<Position6>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="288" TopLine="258"/>
<Caret Line="203" Column="48" TopLine="173"/>
</Position6>
<Position7>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="90" Column="36" TopLine="73"/>
<Caret Line="800" Column="5" TopLine="785"/>
</Position7>
<Position8>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="247" TopLine="224"/>
<Caret Line="190" TopLine="172"/>
</Position8>
<Position9>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="441" Column="79" TopLine="420"/>
<Caret Line="78" TopLine="62"/>
</Position9>
<Position10>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="96" Column="15" TopLine="86"/>
<Caret Line="191" Column="23" TopLine="188"/>
</Position10>
<Position11>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="195" Column="24" TopLine="183"/>
<Caret Line="197" Column="53" TopLine="185"/>
</Position11>
<Position12>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="612" TopLine="594"/>
<Caret Line="206" Column="76" TopLine="179"/>
</Position12>
<Position13>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="87" Column="15" TopLine="63"/>
<Caret Line="76" Column="15" TopLine="61"/>
</Position13>
<Position14>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="281" Column="21" TopLine="272"/>
<Caret Line="814" Column="3" TopLine="810"/>
</Position14>
<Position15>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="811" Column="82" TopLine="793"/>
<Caret Line="78" Column="15" TopLine="59"/>
</Position15>
<Position16>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="136" TopLine="113"/>
<Caret Line="203" Column="68" TopLine="188"/>
</Position16>
<Position17>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="549" Column="70" TopLine="534"/>
<Caret Line="206" Column="66" TopLine="188"/>
</Position17>
<Position18>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="78" Column="15" TopLine="75"/>
<Caret Line="196" TopLine="186"/>
</Position18>
<Position19>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="809" TopLine="793"/>
<Caret Line="198" TopLine="186"/>
</Position19>
<Position20>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="788" TopLine="770"/>
<Caret Line="200" TopLine="186"/>
</Position20>
<Position21>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="792" Column="66" TopLine="770"/>
<Caret Line="196" Column="47" TopLine="186"/>
</Position21>
<Position22>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="87" Column="15" TopLine="61"/>
<Caret Line="195" TopLine="186"/>
</Position22>
<Position23>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="329" Column="59" TopLine="323"/>
<Caret Line="197" TopLine="186"/>
</Position23>
<Position24>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="78" Column="15" TopLine="70"/>
<Caret Line="199" TopLine="186"/>
</Position24>
<Position25>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="789" Column="74" TopLine="781"/>
<Caret Line="200" TopLine="186"/>
</Position25>
<Position26>
<Filename Value="C:\lazarus\lcl\include\wincontrol.inc"/>
<Caret Line="7237" TopLine="7214"/>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="201" TopLine="186"/>
</Position26>
<Position27>
<Filename Value="C:\lazarus\lcl\include\wincontrol.inc"/>
<Caret Line="5898" TopLine="5880"/>
</Position27>
<Position28>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="788" TopLine="781"/>
</Position28>
<Position29>
<Filename Value="usimplelazosrbrowser.pas"/>
<Caret Line="789" TopLine="781"/>
</Position29>
<Position30>
<Filename Value="..\..\source\uCEFMiscFunctions.pas"/>
<Caret Line="1519" Column="23" TopLine="1508"/>
</Position30>
</JumpHistory>
</ProjectSession>
</CONFIG>

View File

@ -91,6 +91,7 @@ object Form1: TForm1
Top = 21
Width = 800
Align = alClient
OnUTF8KeyPress = Panel1UTF8KeyPress
Caption = 'Panel1'
TabOrder = 1
TabStop = True
@ -102,7 +103,6 @@ object Form1: TForm1
OnMouseUp = Panel1MouseUp
OnMouseWheel = Panel1MouseWheel
OnKeyDown = Panel1KeyDown
OnKeyPress = Panel1KeyPress
OnKeyUp = Panel1KeyUp
OnResize = Panel1Resize
end

View File

@ -75,7 +75,7 @@ type
procedure Panel1MouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
procedure Panel1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure Panel1KeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure Panel1KeyPress(Sender: TObject; var Key: char);
procedure Panel1UTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
@ -185,6 +185,31 @@ begin
PostMessage(Handle, WM_CLOSE, 0, 0);
end;
procedure TForm1.Panel1UTF8KeyPress(Sender: TObject; var UTF8Key: TUTF8Char);
var
TempKeyEvent : TCefKeyEvent;
TempString : UnicodeString;
begin
if Panel1.Focused then
begin
TempString := UTF8Decode(UTF8Key);
if (length(TempString) > 0) then
begin
TempKeyEvent.kind := KEYEVENT_CHAR;
TempKeyEvent.modifiers := GetCefKeyboardModifiers(WParam(TempString[1]), 0);
TempKeyEvent.windows_key_code := ord(TempString[1]);
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;
end;
end;
procedure TForm1.chrmosrBeforePopup(Sender: TObject;
const browser: ICefBrowser; const frame: ICefFrame; const targetUrl,
targetFrameName: ustring; targetDisposition: TCefWindowOpenDisposition;
@ -779,25 +804,6 @@ begin
chrmosr.SendFocusEvent(False);
end;
procedure TForm1.Panel1KeyPress(Sender: TObject; var Key: char);
var
TempKeyEvent : TCefKeyEvent;
begin
if Panel1.Focused then
begin
TempKeyEvent.kind := KEYEVENT_CHAR;
TempKeyEvent.modifiers := GetCefKeyboardModifiers(WParam(Key), 0);
TempKeyEvent.windows_key_code := ord(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;
end;
procedure TForm1.Panel1KeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
var
TempKeyEvent : TCefKeyEvent;

View File

@ -108,13 +108,15 @@ type
property Alignment;
property Anchors;
property AutoSize;
{$IFNDEF FPC}
{$IFDEF FPC}
property OnUTF8KeyPress;
{$ELSE}
property BevelEdges;
property BevelKind;
property Ctl3D;
property Locked;
property ParentBackground;
property ParentCtl3D;
property BevelKind;
property Ctl3D;
property Locked;
property ParentBackground;
property ParentCtl3D;
property OnCanResize;
{$ENDIF}
property BevelInner;